Face Detection
Introduction
MindFace is an open source toolkit based on MindSpore and currently contains state-of-the-art face recognition and detection models such as ArcFace, RetinaFace, etc. MindFace has a unified application programming interface and powerful scalability for common application scenarios such as facial recognition and detection.
This is a face detection repository for the MindFace. The deep learning models currently available for users are RetinaFace network models based on different backbone networks (resnet50 and mobiletnet0.25). RetinaFace is a single-stage SOTA face detector which is accepted by CVPR 2020. The ResNet50-based version we implemented provides better performance, while the MobileNet0.25-based version is faster to detect.
Results
WiderFace Val Performance in multiscale.
backbone |
Easy |
Medium |
Hard |
ResNet50 |
95.81% |
94.89% |
90.10% |
WiderFace Val Performance in single scale When using ResNet50 as backbone.
Style |
Easy |
Medium |
Hard |
MindSpore (same parameter with MXNet) |
94.46% |
93.64% |
89.42% |
MindSpore (original image scale) |
95.07% |
93.61% |
84.84% |
PyTorch (same parameter with MXNet) |
94.82 % |
93.84% |
89.60% |
PyTorch (original image scale) |
95.48% |
94.04% |
84.43% |
MXNet |
94.86% |
93.87% |
88.33% |
MXNet(original image scale) |
94.97% |
93.89% |
82.27% |
Quick Start
-
Installation
1.1 Git clone this repo and install RetinaFace_resnet50.
git clone https://openi.pcl.ac.cn/lemon/mindface_retinaface_resnet50.git
cd mindface_retinaface_resnet50
1.2 Install dependencies
cd mindface_retinaface_resnet50/
pip install -r requirements.txt
-
Prepare Data
2.1. Download WiderFace dataset and annotations that we used from baidu cloud or google drive.
2.2. Organise the dataset directory under mindface_retinaface_resnet50 as follows:
data/WiderFace/
train/
images/
label.txt
val/
images/
label.txt
ground_truth/
wider_easy_val.mat
wider_medium_val.mat
wider_hard_val.mat
wider_face_val.mat
-
Set Config File
You can Modify the parameters of the config file in ./configs
.
We provide config (RetinaFace_resnet50).
-
Training
It is easy to train your model using train.py
, where the training strategy (e.g., augmentation, LR scheduling) can be configured with external arguments or a yaml config file.
python mindface_retinaface_resnet50/train.py --config mindface_retinaface_resnet50/configs/RetinaFace_resnet50.yaml
export CUDA_VISIBLE_DEVICES=0,1,2,3 # 4 GPUs
mpirun -n 4 python mindface_retinaface_resnet50/train.py --config mindface_retinaface_resnet50/configs/RetinaFace_resnet50.yaml
note: if your device is Ascend, please set the "device_target" in the config file to "Ascend".
-
Validation
To evalute the model performance, please run eval.py
python eval.py --config mindface_retinaface_resnet50/configs/RetinaFace_resnet50.yaml --checkpoint pretrained/weight.ckpt
-
Inference
To infer a single image, please run infer.py
python infer.py --config mindface_retinaface_resnet50/configs/RetinaFace_resnet50.yaml --checkpoint pretrained/weight.ckpt --image_path ./imgs/0000.jpg --conf 0.5
Demo
The inference results by using our pre-trained weights are shown in the following figure.
RetinaFace Pretrained Models
You can download our pretrained model of RetinaFace-ResNet50.
You can verify the results in the table with the downloaded pretrained model.
References
@inproceedings{deng2019retinaface,
title={RetinaFace: Single-stage Dense Face Localisation in the Wild},
author={Deng, Jiankang and Guo, Jia and Yuxiang, Zhou and Jinke Yu and Irene Kotsia and Zafeiriou, Stefanos},
booktitle={arxiv},
year={2019}