python中的2d或3d人脸标记检测器
face-alignment的Python项目详细描述
人脸识别
使用世界上最精确的面部定位网络,从python中检测面部地标,该网络能够检测二维和三维坐标中的点。
使用FAN最先进的基于深度学习的人脸对齐方法构建。
注意:lua版本可用here。
对于数值计算,强烈建议使用lua版本,该版本使用与本文所评估的模型相同的模型。不久将增加更多型号。
功能
检测图片中的二维面部标志
importface_alignmentfromskimageimportiofa=face_alignment.FaceAlignment(face_alignment.LandmarksType._2D,flip_input=False)input=io.imread('../test/assets/aflw-test.jpg')preds=fa.get_landmarks(input)
检测图片中的三维面部标志
importface_alignmentfromskimageimportiofa=face_alignment.FaceAlignment(face_alignment.LandmarksType._3D,flip_input=False)input=io.imread('../test/assets/aflw-test.jpg')preds=fa.get_landmarks(input)
一次性处理整个目录
importface_alignmentfromskimageimportiofa=face_alignment.FaceAlignment(face_alignment.LandmarksType._2D,flip_input=False)preds=fa.get_landmarks_from_directory('../test/assets/')
使用特定的面部探测器检测路标。
默认情况下,软件包将使用SFD面部探测器。然而,用户可以交替使用预先保存的或已存在的地面真相包围盒。
importface_alignment# sfd for SFD, dlib for Dlib and folder for existing bounding boxes.fa=face_alignment.FaceAlignment(face_alignment.LandmarksType._2D,face_detector='sfd')
在CPU/GPU上运行
为了指定运行代码的设备(GPU或CPU),可以显式地传递设备标志:
importface_alignment# cuda for CUDAfa=face_alignment.FaceAlignment(face_alignment.LandmarksType._2D,device='cpu')
另请参见examples
文件夹
安装
要求
- Python3.5+或Python2.7(也可以与其他版本一起使用)
- Linux、Windows或MacOS
- 喷灯(>;=0.4)
虽然不是必需的,但为了获得最佳性能(特别是对于检测器),建议使用启用CUDA的GPU运行代码。
二进制文件
conda install -c 1adrianb face_alignment
来源
安装pytorch和pytorch依赖项。来自pytorch readme的指令。有关更新版本,请查看framework github页面。
在Linux上
exportCMAKE_PREFIX_PATH="$(dirname $(which conda))/../"# [anaconda root directory]# Install basic dependencies conda install numpy pyyaml mkl setuptools cmake gcc cffi # Add LAPACK support for the GPU conda install -c soumith magma-cuda80 # or magma-cuda75 if CUDA 7.5
在OSX上
exportCMAKE_PREFIX_PATH=[anaconda root directory] conda install numpy pyyaml setuptools cmake cffi
获取pytorch源
git clone --recursive https://github.com/pytorch/pytorch
安装pytorch
在Linux上
python setup.py install
在OSX上
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install
获取面部定位源代码
git clone https://github.com/1adrianb/face-alignment
安装面对齐库
pip install -r requirements.txt
python setup.py install
Docker图像
提供Dockerfile来构建具有CUDA支持和CUDNN V5的映像。有关运行和构建Docker映像的更多说明,请查看Docker原始文档。
docker build -t face-alignment .
它是如何工作的?
虽然这里的工作是一个黑箱,如果你想知道更多关于方法的内联,请在ARXIV或我的^ {A7}上检查原始文件。贡献
欢迎所有捐款。如果您遇到任何问题(包括失败的图像示例),请随意打开问题。
引文
@inproceedings{bulat2017far,
title={How far are we from solving the 2D \& 3D Face Alignment problem? (and a dataset of 230,000 3D facial landmarks)},
author={Bulat, Adrian and Tzimiropoulos, Georgios},
booktitle={International Conference on Computer Vision},
year={2017}
}
如需引用dlib、pytorch或此处使用的任何其他包,请查看其各自作者的原始页面。
致谢
- 感谢pytorch团队提供了如此棒的深度学习框架
- 感谢他的耐心和建议。
- 所有其他python开发人员都可以使用此存储库中使用的其余包。