Face Alignment is a Python library for detecting facial landmarks in 2D and 3D coordinates using deep learning.
The library solves the problem of accurately localizing facial keypoints in images. It uses the FAN (Face Alignment Network) method, a state-of-the-art deep learning approach built on PyTorch. The tool can detect landmarks in both 2D and 3D space and process entire directories of images. It includes a pluggable face detection system, defaulting to SFD but supporting multiple backends including BlazeFace, YuNet, RetinaFace, and SCRFD, each offering different trade-offs between accuracy and speed. Users can also skip detection by loading pre-computed bounding boxes from files, which is useful for evaluation with ground truth data.
Developers should choose this library if they need accurate facial landmark detection in Python with flexibility around face detection methods. It suits projects requiring both 2D and 3D landmark coordinates and those that need to balance speed versus accuracy in the detection pipeline. The tool runs on CPU or GPU and uses torch.compile for faster inference, with compilation artifacts cached after the first run. Installation is straightforward via pip or conda, requiring Python 3.9 or later and PyTorch 2.0 or newer. For numerical evaluations requiring exact reproducibility with published results, the README recommends using the Lua version instead.
The project maintains active development with regular updates to supported face detectors and optimization features. The codebase includes comprehensive examples demonstrating various use cases. The tool has been refined to support modern PyTorch features and multiple hardware acceleration options including CUDA and Apple's MPS. Documentation covers installation from binaries, source builds, and Docker deployment, indicating attention to accessibility across different development environments.