版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chenzhenyu123456/article/details/80751477
看paper和algorithm时间长了也会累,抽时间动动手也是很有好处的。但没想到汇总一个人脸识别Demo发到Github上花这么长时间 (ˉ▽ˉ;)…不管怎么样,希望对大家有所帮助。
Demo地址:Github
Introduction
这是我在Pycharm IDE下结合MTCNN[1] 和FaceNet[2] 实现的,它可以对任意的数据集进行训练并实现人脸验证、人脸识别和人脸查找的功能。最后,我使用Tkinter制作了用户界面,使用者可以很方便的进行操作。如果你想学习人脸识别或者Tkinter UI的话,我相信我的项目会对你有所帮助。
这里我使用的是英文界面(虽然朋友同意我放网上,但直接用中文标注名字感觉不太好),大家在程序中可以自行选择中英文(修改language = ‘chinese’ or ‘english’)。
Results
- 人脸验证 (验证
ChenZhenyu
)
Successful verification! This image was identified as ChenZhenyu!
- 人脸识别
Detected LiuXin,YangShuntao,LiJialong,ChenZhenyu,LiuKe,ZhangYuchan,ZhangJinrui in this image!
- 人脸查找 (search
ChenZhenyu
,LiuKe
)
Found ChenZhenyu,LiuKe in this image!
Environment
- Windows 10
Python 3.6.4 + TensorFlow 1.6.0 + tk 8.5.19 + dlib 19.4 + opencv 3.4.1 + scikit-image 0.13.0 + scikit-learn 0.19.1 - Ubuntu 16.04
Python 3.6.2 + TensorFlow 1.3.0 + tk 8.5.18 + dlib 19.4 + opencv 3.1.0 + scikit-image 0.13.0 + scikit-learn 0.19.0
建议在Ubuntu下使用英文,Windows系统下中英文均可。
UI Display
Windows (程序同样可以运行在Ubuntu系统)
Login
Train
Retrieval
搜索图片,在检索UI的右侧展示它们。
Predict
可以在预测UI的右侧可视化最后的图像结果
Notebook Display
你可以通过 face_recognition_process.ipynb 来了解详细流程。
How to use it
- 下载资源并将它们放入
resources
文件夹下
Google Driver: https://drive.google.com/file/d/19WKS0aDJy9ncmWCR8ScvcmEU8tmDZoEM/view?usp=sharing
BaiDu Cloud: https://pan.baidu.com/s/1SOBR0eUQvUyYutuhHxLfsQ - 下载MTCNN的权值并将它们放入目录
models/mtcnn
Google Driver: https://drive.google.com/file/d/12r98MQsxy4_cPekGpQD7BknPm5Tdyd7b/view?usp=sharing
BaiDu Cloud: https://pan.baidu.com/s/178wilMLklTdjavE5k_SRDA - 下载FaceNet权值并将它放入目录
models/20170512-110547
Google Driver: https://drive.google.com/file/d/1aQjhcidR3z2YbjB0qYIFDpJChiP3n7Zy/view?usp=sharing
BaiDu Cloud: https://pan.baidu.com/s/15UsfsxfLu3iSZSfuqVmx-g - 如果你需要使用人脸校正,你需要下载模型并将它放入目录
models
Google Driver: https://drive.google.com/file/d/1C09m6bb2MAkM4G3cBhtsuRuW3S-qmgD5/view?usp=sharing
BaiDu Cloud: https://pan.baidu.com/s/1uUCs9HaKtkv6Q5ST55nLbw - 在做完上面的步骤之后,你可以在notebook上实现人脸识别的功能
- 如果你需要使用UI,下载我的项目并在PyCharm下打开,运行
ui_with_tkinter/choose_language.py
即可
Folder Structure
models/
----------20170512-110547/
--------------------20170512-110547.pd
--------------------model-20170512-110547.ckpt-250000.data-00000-of-00001
--------------------model-20170512-110547.ckpt-250000.index
--------------------model-20170512-110547.meta
----------mtcnn/
--------------------det1.npy
--------------------det2.npy
--------------------det3.npy
----------my_models/
----------shape_predictor_68_face_landmarks.dat
dataset/
----------train_english/
--------------------XiaoMing/
------------------------------XiaoMing1.jpg
------------------------------...
--------------------XiaoHu/
------------------------------XiaoHu1.jpg
------------------------------...
--------------------...
----------train_chinese/
--------------------小明/
------------------------------XiaoMing1.jpg
------------------------------...
--------------------小虎/
------------------------------XiaoHu1.jpg
------------------------------...
--------------------...