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

世界上最简单的面部识别为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/
文件夹前面没有点
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值