Giter VIP home page Giter VIP logo

face's Introduction


不要学我!

  • 正式建立你的第一个Github项目前,建议先阅读Github 文档
  • 不要在一个提交中包含 1378 个修改
  • 提交最好遵循 Conventional Commits 规范,不要写一堆诡异的随机字符
  • 最好不要直接把数据集放在代码仓库里,如果需要分享数据集,可以上传到 kaggle 上。
  • 注意代码风格保持统一,可以使用 EditorConfig 来规范代码格式。
  • 最好使用 .gitattribute 来规范行分隔符,参考模板
  • 注意在 .gitignore 中忽略不必要的文件和目录,例如 .vscode, .idea
  • README 应当简洁明了,发布在github上的README最好支持中英双语
  • 最好附上开源协议

任务

  • 用feature tensor来计算欧式距离(可以用tensor,也可以转numpy)
  • 画1000个不同人特征的欧式距离的点和1000个相同人图片的特征的欧式距离
  • 附加题 用获取的feature 和 label来做分类(参考上一次的逻辑回归)

每个文件的作用

./writeFeature.py 节省时间

把每张图片的特征算出来后直接保存到一些 .txt 文件里。

虽然体积有点大,但是可以加快速度。

作业 [0, 1]

就是用 matplotlib 把图像画出来

顺便计算 "用来区分是否为同一人" 的阈值,如果欧氏距离大于这个阈值就可以认为不是同一人。

作业 [2] 性别分类 classification

我用两个函数模型分别试了试

模型1:

# 训练集准确率
: 0.938
男性: 0.927
女性: 0.893
# 测试集准确率
: 0.805
男性: 0.671
女性: 0.934

模型2:

# 训练集准确率
: 0.889
男性: 0.898
女性: 0.88
# 测试集准确率
: 0.859
男性: 0.780
女性: 0.934

先获取图像特征(长度为 512 的向量),然后在后边加一个 1, 向量长度变成 513,记为 a

文件 target.txt 里有 513 个训练好的参数,这些参数组成一个向量,记为 b

计算 $sigmoid(sum(\pmb{a} · \pmb{b}) )$ 的值

如果大于 0.5,判断为男性

如果小于 0.5,判断为女性

python 实在是太慢了,算到虎年都算不完👴 也许因为我的 GPU 是 MX350?

所以我把 train.py 移植到了 train.java, 用 [这个bat脚本](classification/compile and run.bat) 编译并运行。每次运行训练的步数是写在 train.java 源码里的。

每训练一定步数,就会把结果写在 target.txt 里。随时可以用它们做测试。

target.txt 文件中的参数做测试,计算这堆参数在测试集的准确率。

画出测试集中图片的性别预测值的分布图像

懒得 ctrl+C ctrl + V,所以用这个脚本每隔60s备份一次target.txt

就是复制到 backups文件夹里,然后文件名后边加个时间

根据 backup 中的数据绘制各参数的值随时间的变化的图像`

通过图像可以发现,很多参数的变化趋势近似抛物线或者双勾函数

  • [compile and run.bat](classification/compile and run.bat) 编译并运行train.java

只是因为懒得换 IDE

先获得特征:$ p = [x_1, x_2, ..., x_{513}] $

然后将 p 化成 :$a = [p · p, p, 1] = [x_1^2, x_2^2, ..., x_{513}^2, x_1, x_2, ..., x_{513}, 1]$

此时 a 的长度是1025,target.txt 中的向量 b长度也是 1025

计算 $sigmoid(sum(\pmb{a} · \pmb{b}) )$ 的值

如果大于 0.5,判断为男性

如果小于 0.5,判断为女性

然后文件夹里的各个文件作用和 模型1 的相同。

人脸识别 recognition

如果电脑有摄像头,可以直接运行该文件进行注册。

如果没有,也可以把 图像.jpg(.png...) 放在文件夹./recognition/account里,然后直接运行register.py

通过摄像头实时获取图像,提取特征,与文件夹account里的*.txt中的特征相比对,找出最相似的人

原理就是计算特征的欧氏距离。

face's People

Contributors

leawind avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.