MindFace人脸检测库
简介
MindFace是一款基于MindSpore的开源工具包,目前包含最先进的人脸识别和检测模型,如ArcFace、RetinaFace等。MindFace有统一应用程序编程接口和强大的可扩展性,可以用于面部识别和检测等常见应用场景。
本仓库为MindFace人脸套件的人脸检测库。目前可供用户使用的深度学习模型有基于不同骨干网络(resnet50和mobiletnet0.25)实现的RetinaFace网络模型。
RetinaFace是一种实用的单级SOTA人脸检测器,被CVPR 2020会议收录。其中,我们实现的基于ResNet50的版本能提供更好的精度,而基于MobileNet0.25的轻量版本,检测速度更快。
性能
使用backbone进行多尺度测试在WiderFace Val数据集上的表现.
backbone |
Easy |
Medium |
Hard |
ResNet50 |
95.81% |
94.89% |
90.10% |
使用Resnet50作为backbone进行单尺度测试在WiderFace Val数据集上的表现.
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% |
快速入门
-
安装
1.1 从此处下载mindface_retinaface_resnet50仓库并安装mindface_retinaface_resnet50
git clone https://openi.pcl.ac.cn/lemon/mindface_retinaface_resnet50.git
cd mindface_retinaface_resnet50
1.2 安装依赖包
cd mindface_retinaface_resnet50/
pip install -r requirements.txt
-
数据集准备
2.1. 从百度云或谷歌云盘下载WiderFace数据集和标签。
2.2. 在 mindface_retinaface_resnet50 目录下存放数据集,结构树如下所示:
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
-
修改配置文件
请在配置文件 ./configs
中修改参数.
我们提供了配置文件(RetinaFace_resnet50).
-
训练
通过运行train.py
可以训练你自己的人脸检测模型,使用的模型方法和训练策略可以通过命令行参数或者yaml配置文件来配置。
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
注意:如果你的设备是Ascend,请在配置文件中设置 "device_target "为 "Ascend"。
-
验证
通过运行eval.py
可以对模型在WiderFace上的性能做评估。
python eval.py --config mindface_retinaface_resnet50/configs/RetinaFace_resnet50.yaml --checkpoint pretrained/weight.ckpt
-
推理
通过运行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
推理结果示意图
RetinaFace预训练模型
从此处下载预训练模型
RetinaFace-ResNet50。
你可以在此表格中核验预训练模型和结果。
参考
@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}