您的位置:首页 > 编程语言 > Python开发

世界上最简单的面部识别为Python和命令行api

2018-01-23 20:14 357 查看
世界上最简单的面部识别为Python和命令行api https://github.com/ageitgey/face_recognition
模型使用了C++工具箱dlib基于深度学习的最新人脸识别方法,基于户外脸部数据测试库Labeled Faces in the Wild 的基准水平来说,达到了99.38%的准确率。
dlib:http://dlib.net/
数据测试库Labeled Faces in the Wild:http://vis-www.cs.umass.edu/lfw/
模型提供了一个简单的 face_recognition 命令行工具让用户通过命令就能直接使用图片文件夹进行人脸识别操作。

安装
pip3 install face_recognition
如果报错:ubuntu下安装dlib,http://blog.csdn.net/funny75/article/details/51582056
dlib官网 http://dlib.net/compile.html 进入官网下载安装包,解压后放到 /usr/local/lib/python2.7/dist-packages 目录下(或者3.5,根据自己的python版本选择)
安装编译所需工具 
sudo apt-get install cmake 
(如果报错:软件包 cmake 没有可安装候选,先sudo apt-get update)
sudo apt-get install libboost-python-dev

进入dlib的目录 
sudo python3 setup.py install
(如果发生错误:python-3-importerror-no-module-named-setuptools,先对于Python 3. x
sudo apt-get install python3-setuptools)
(如果发生错误:/usr/local/lib/python3.5/dist-packages/dlib-19.10/dlib/external/pybind11/include/pybind11/detail/common.h:111:20: fatal error: Python.h: 没有那个文件或目录:那么:sudo apt install python3.5-dev)

然后再 运行pip3 install face_recognition来完成安装。
测试:
接下来你只用运行face_recognition命令,程序能够通过已知人脸的文件夹识别出未知人脸照片中的人是谁;
 
针对每个人脸都要一行输出,数据是文件名加上识别到的人名,以逗号分隔。
如果你只是想要知道每个照片中的人名而不要文件名,可以进行如下操作:
 
Python模块,实现人脸识别
你可以通过引入face_recognition就能完成人脸识别操作:
API 文档: https://face-recognition.readthedocs.io.
在图片中自动识别所有人脸
请参照此案例: https://github.com/ageitgey/face_recognition/blob/master/examples/find_faces_in_picture.py
识别图片中的人脸并告知姓名
请参照此案例this example: https://github.com/ageitgey/face_recognition/blob/master/examples/recognize_faces_in_pictures.py
Python代码案例
所有例子在此 here. https://github.com/ageitgey/face_recognition/tree/master/examples
找到照片中的人脸 https://github.com/ageitgey/face_recognition/blob/master/examples/find_faces_in_picture.py
识别照片中的面部特征Identify specific facial features in a photograph https://github.com/ageitgey/face_recognition/blob/master/examples/find_facial_features_in_picture.py
使用数字美颜Apply (horribly ugly) digital make-up https://github.com/ageitgey/face_recognition/blob/master/examples/digital_makeup.py
基于已知人名找到并识别出照片中的未知人脸Find and recognize unknown faces in a photograph based on photographs of known people https://github.com/ageitgey/face_recognition/blob/master/examples/recognize_faces_in_pictures.py
人脸识别方法的原理
如果你想学习此方法的人脸定位和识别原理,请参见read my article。 https://medium.com/@ageitgey/machine-learning-is-fun-part-4-modern-face-recognition-with-deep-learning-c3cffc121d78
注意事项
· 本人脸识别模型仅限用于成人,对于儿童来说效果不佳,模型可能会由于使用默认的对比阈值(0.6)而无法清楚识别出儿童的脸。

dlib 文档
opencv文档
中文网:http://www.opencv.org.cn/

face_recognition文档,源码 https://facerecognition.readthedocs.io/en/latest/face_recognition.html face_recognition --tolerance 0.54 /home/double/dlib_data/train/ /home/double/dlib_data/test/
文件夹前面没有点
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  安装