1adrianb/face-alignment là dự án tích hợp AI trên GitHub với 7.6k sao, viết chủ yếu bằng Python. :fire: 2D and 3D Face alignment library build using pytorch
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Detect facial landmarks from Python using the world's most accurate face alignment network, capable of detecting points in both 2D and 3D coordinates.
Build using FAN's state-of-the-art deep learning based face alignment method.
Note: The lua version is available here.
For numerical evaluations it is highly recommended to use the lua version which uses indentical models with the ones evaluated in the paper. More models will be added soon.
Features
Detect 2D facial landmarks in pictures
import face_alignment
from skimage import io
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, flip_input=False)
input = io.imread('../test/assets/aflw-test.jpg')
preds = fa.get_landmarks(input)
Detect 3D facial landmarks in pictures
import face_alignment
from skimage import io
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.THREE_D, flip_input=False)
input = io.imread('../test/assets/aflw-test.jpg')
preds = fa.get_landmarks(input)
Process an entire directory in one go
import face_alignment
from skimage import io
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, flip_input=False)
preds = fa.get_landmarks_from_directory('../test/assets/')
Detect the landmarks using a specific face detector.
By default the package will use the SFD face detector. Pass face_detector to switch:
import face_alignment
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, face_detector='sfd')
Supported face detectors
The library supports multiple face detection backends. SFD is the default and most accurate, but slower alternatives like BlazeFace, YuNet, or RetinaFace offer better speed. SCRFD requires the optional onnxruntime package (pip install onnxruntime).
Detector
face_detector=
CPU (ms)
MPS (ms)
PyTorch device
SFD
'sfd'
138.8
33.1
CPU / CUDA / MPS
BlazeFace
'blazeface'
10.9
8.2
CPU / CUDA / MPS
YuNet
'yunet'
5.6
N/A
CPU only (OpenCV DNN)
RetinaFace
'retinaface'
25.2
15.5
CPU / CUDA / MPS
SCRFD
'scrfd'
23.1
N/A
CPU only (ONNX Runtime)
dlib(deprecated)
'dlib'
—
—
CPU / CUDA
Timings: detection only, median over 20 runs, single face 450x450 image, Apple M2.
You can also skip detection entirely by passing face_detector='folder', which loads pre-computed bounding boxes from .npy, .t7, or .pth files matching each image filename. This is useful for evaluation with ground truth boxes.
import face_alignment
# BlazeFace back camera model (larger input, better for distant faces)
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, face_detector='blazeface',
face_detector_kwargs={'back_model': True})
# SCRFD (requires: pip install onnxruntime)
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, face_detector='scrfd')
# Use pre-computed bounding boxes from files alongside images
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, face_detector='folder')
Running on CPU/GPU
In order to specify the device (GPU or CPU) on which the code will run one can explicitly pass the device flag.
The landmark network is compiled with torch.compile by default for faster inference. Compilation artifacts are cached to disk, so only the first run is slow (~25s). Pass compile=False to disable.
import torch
import face_alignment
# cuda for CUDA, mps for Apple M GPUs.
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, dtype=torch.bfloat16, device='cuda')
# Skip compilation for instant startup
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, device='cpu', compile=False)
# Limit batch size for multi-face images on low-memory GPUs (default: 1)
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, device='cuda', max_batch_size=8)
Please also see the examples folder
Installation
Requirements
Python 3.9+
Linux, Windows or macOS
PyTorch (>=2.0)
While not required, for optimal performance(especially for the detector) it is highly recommended to run the code using a CUDA enabled GPU.
Binaries
The easiest way to install it is using either pip or conda:
pip install face-alignment
Alternatively, you can build it from source.
From source
Install pytorch and pytorch dependencies. Please check the pytorch readme for this.
A Dockerfile is provided to build images with cuda support and cudnn. For more instructions about running and building a docker image check the orginal Docker documentation.
docker build -t face-alignment .
How does it work?
While here the work is presented as a black-box, if you want to know more about the intrisecs of the method please check the original paper either on arxiv or my webpage.
Contributions
All contributions are welcomed. If you encounter any issue (including examples of images where it fails) feel free to open an issue. If you plan to add a new features please open an issue to discuss this prior to making a pull request.
Citation
@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}
}
For citing dlib, pytorch or any other packages used here please check the original page of their respective authors.
Acknowledgements
To the pytorch team for providing such an awesome deeplearning framework
To my supervisor for his patience and suggestions.
To all other python developers that made available the rest of the packages used in this repository.
1adrianb/face-alignment có 7.6k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/1adrianb/face-alignment. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
1adrianb/face-alignment có phải mã nguồn mở không?
Có — 1adrianb/face-alignment phát hành theo license BSD-3-Clause, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/1adrianb/face-alignment.
1adrianb/face-alignment còn đang phát triển không?
Commit gần nhất trên 1adrianb/face-alignment là 7 tháng trước (theo timestamp GitHub). Repo có 1.4k fork — một chỉ báo về mức độ quan tâm của cộng đồng.
1adrianb/face-alignment là gì?
1adrianb/face-alignment (1adrianb/face-alignment) là dự án Python trên GitHub. Theo mô tả gốc: :fire: 2D and 3D Face alignment library build using pytorch
1adrianb/face-alignment so với các dự án AI Tools khác thế nào?
1adrianb/face-alignment được TopGit xếp vào nhóm AI Tools, với 7.6k sao GitHub và viết bằng Python. Xem trang chủ đề AI Tools trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Đọc thêm về 1adrianb/face-alignment ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/1adrianb/face-alignment là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về face-alignment?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về face-alignment.