Home

Awesome

Pytorch Face Landmark Detection

Implementation of face landmark detection with PyTorch. The models were trained using coordinate-based or heatmap-based regression methods. Different face detetors were supported. A video demo and image detection results were displayed here.

Inference

Test on a sample folder and save the landmark detection and cropped face results. Support different backbones and face detectors.

python3 test_batch_detections.py --backbone MobileFaceNet --detector Retinaface

Optimize with ONNX and test on a camera with MTCNN as a face detector.

python3 test_camera_mtcnn_onnx.py

Optimize with ONNX and test on a camera with a lightweight face detector. It can achieve real-time speed on CPU.

python3 test_camera_light_onnx.py

Optimize with OpenVINO and test on a camera with a lightweight face detector. About 10 times faster than ONNX.

python3 test_camera_mobilefacenet_openvino.py

Benchmark Results on 300W

AlgorithmsCommonChallengeFull SetParam # (M)
ResNet18 (224×224)3.737.144.3911.76
Res2Net50_v1b (224×224)3.436.774.0726.00
Res2Net50_v1b_SE (224×224)3.376.674.0127.05
Res2Net50_v1b_ExternalData (224×224)3.305.923.8126.00
HRNet_w18_small_v2 (224×224)3.576.854.2013.83
AlgorithmsCommonChallengeFull SetParam # (M)CPU Inference (s)
MobileNetV2 (224×224)3.707.274.393.741.2
MobileNetV2_SE (224×224)3.637.014.284.15/
MobileNetV2_SE_RE (224×224)3.636.664.214.15/
MobileNetV2_ExternalData (224×224)3.486.03.963.741.2
MobileNetV2 (56×56)4.508.505.273.740.01 (onnx)
MobileNetV2_SE_ExternalData (56×56)4.106.894.644.100.01 (onnx)
PFLD_ExternalData (112×112)3.496.013.970.730.01 (onnx)
MobileFaceNet_ExternalData (112×112)3.305.693.761.01/

Note: SE (squeeze-and-excitation module), RE (random erasing module).

AlgorithmsCommonChallengeFull SetParam # (M)
Hourglass23.065.543.558.73

Visualization Results

img1

img1

img1

TODO

The following features will be added soon.

Public Datasets:

Citations:

If you use library in your project, please, cite it as follows.

@misc{PFL,
  title={{PyTorch Face Landmark}: A Fast and Accurate Facial Landmark Detector},
  url={https://github.com/cunjian/pytorch_face_landmark},
  note={Open-source software available at https://github.com/cunjian/pytorch_face_landmark},
  author={Cunjian Chen},
  year={2021},
}

References: