face_alignment库的简介
使用世界上最精确的面部定位网络,从Python中检测面部地标,该网络能够检测二维和三维坐标中的点。它使用了FAN最先进的基于深度学习的面部对齐方法。
Github地址:https://github.com/1adrianb/face-alignment
1、指定在CPU / GPU上运行
import face_alignment
# cuda for CUDA
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, device='cpu')
2、使用特定的面部检测器检测地标。
默认情况下,该包将使用SFD面部检测器。但是,用户也可以选择使用dlib或预先存在的地面真实边界框。
import face_alignment
# sfd for SFD, dlib for Dlib and folder for existing bounding boxes.
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, face_detector='sfd')
3、一次性处理整个目录
import face_alignment
from skimage import io
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, flip_input=False)
preds = fa.get_landmarks_from_directory('../test/assets/')
face_alignment库的安装
pip install face-alignment
face_alignment库的使用方法
1、检测图像中的二维、三维人脸标志
import face_alignment
from skimage import io
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, flip_input=False)
input = io.imread('../test/assets/aflw-test.jpg')
preds = fa.get_landmarks(input)
import face_alignment
from skimage import io
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._3D, flip_input=False)
input = io.imread('../test/assets/aflw-test.jpg')
preds = fa.get_landmarks(input)
————————————————