# Face-Detector-1MB-with-landmark
## 实现功能
- Retinaface-mobile0.25的训练/测试/评估/ncnn C++推理
- Face-Detector-1MB slim和RFB版本的训练/测试/评估/ncnn C++推理
- 人脸5个关键点检测
- 支持onnx导出
- 网络parameter和flop计算
# 带有关键点检测的超轻量级人脸检测器
提供了一系列适合移动端部署包含关键的人脸检测器: 对[Retinaface-mobile0.25](https://github.com/biubug6/Pytorch_Retinaface)修改anchor尺寸,使其更适合边缘计算; 重新实现了[Face-Detector-1MB](https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB) 并添加了关键点检测和ncnn C++部署功能, 在绝大部分情况下精度均好于原始版本.
<p align="center"><img src="img/1.jpg"\></p>
## 测试的运行环境
- Ubuntu18.04
- Python3.7
- Pytorch1.2
- CUDA10.0 + CUDNN7.5
## 精度
### Widerface测试
- 在wider face val精度(单尺度输入分辨率:**320*240**)
方法|Easy|Medium|Hard
------|--------|----------|--------
libfacedetection v1(caffe)|0.65 |0.5 |0.233
libfacedetection v2(caffe)|0.714 |0.585 |0.306
version-slim(原版)|0.765 |0.662 |0.385
version-RFB(原版)|0.784 |0.688 |**0.418**
version-slim(our)|0.795 |0.683 |0.34.5
version-RFB(our)|**0.814** |**0.710** |0.363
Retinaface-Mobilenet-0.25(our) |0.811|0.697|0.376
- 在wider face val精度(单尺度输入分辨率:**640*480**)
方法|Easy|Medium|Hard
------|--------|----------|--------
libfacedetection v1(caffe)|0.741 |0.683 |0.421
libfacedetection v2(caffe)|0.773 |0.718 |0.485
version-slim(原版)|0.757 |0.721 |0.511
version-RFB(原版)|0.851 |0.81 |0.541
version-slim(our)|0.850 |0.808 |0.595
version-RFB(our)|0.865 |0.828 |0.622
Retinaface-Mobilenet-0.25(our) |**0.873**|**0.836**|**0.638**
ps: 测试的时候,长边为320 或者 640 ,图像等比例缩放.
## Parameter and flop
方法|parameter(M)|flop(M)
------|--------|----------
version-slim(our)|0.343 |98.793
version-RFB(our)|0.359 |118.435
Retinaface-Mobilenet-0.25(our) |0.426|193.921
ps: 320*240作为输入
### Contents
- [Installation](#installation)
- [Training](#training)
- [Evaluation](#evaluation)
- [C++_inference _ncnn](#c++_inference_ncnn)
- [References](#references)
## Installation
##### Clone and install
1. git clone https://github.com/biubug6/Face-Detector-1MB-with-landmark.git
2. Pytorch version 1.1.0+ and torchvision 0.3.0+ are needed.
3. Codes are based on Python 3
##### Data
1. The dataset directory as follows:
```Shell
./data/widerface/
train/
images/
label.txt
val/
images/
wider_val.txt
```
ps: wider_val.txt only include val file names but not label information.
2. We provide the organized dataset we used as in the above directory structure.
Link: from [google cloud](https://drive.google.com/open?id=11UGV3nbVv1x9IC--_tK3Uxf7hA6rlbsS) or [baidu cloud](https://pan.baidu.com/s/1jIp9t30oYivrAvrgUgIoLQ) Password: ruck
## Training
1. Before training, you can check network configuration (e.g. batch_size, min_sizes and steps etc..) in ``data/config.py and train.py``.
2. Train the model using WIDER FACE:
```Shell
CUDA_VISIBLE_DEVICES=0 python train.py --network mobile0.25 or
CUDA_VISIBLE_DEVICES=0 python train.py --network slim or
CUDA_VISIBLE_DEVICES=0 python train.py --network RFB
```
If you don't want to train, we also provide a trained model on ./weights
```Shell
mobilenet0.25_Final.pth
RBF_Final.pth
slim_Final.pth
```
## Evaluation
### Evaluation widerface val
1. Generate txt file
```Shell
python test_widerface.py --trained_model weight_file --network mobile0.25 or slim or RFB
```
2. Evaluate txt results. Demo come from [Here](https://github.com/wondervictor/WiderFace-Evaluation)
```Shell
cd ./widerface_evaluate
python setup.py build_ext --inplace
python evaluation.py
```
3. You can also use widerface official Matlab evaluate demo in [Here](http://mmlab.ie.cuhk.edu.hk/projects/WIDERFace/WiderFace_Results.html)
## C++_inference _ncnn
1. Generate onnx file
```Shell
python convert_to_onnx.py --trained_model weight_file --network mobile0.25 or slim or RFB
```
2. Onnx file change to ncnn(*.param and *.param)
```Shell
cp *.onnx ./Face_Detector_ncnn/tools
cd ./Face_Detector_ncnn/tools
./onnx2ncnn face.param face.bin
```
3. Move *.param and *.bin to model
```Shell
cp face.param ../model
cp face.bin ../model
```
4. Build Project(set opencv path in CmakeList.txt)
```Shell
mkdir build
cd build
cmake ..
make -j4
```
5. run
```Shell
./FaceDetector *.jpg
```
We also provide the converted file in "./model".
```Shell
face.param
face.bin
```
## References
- [FaceBoxes](https://github.com/zisianw/FaceBoxes.PyTorch)
- [Retinaface (mxnet)](https://github.com/deepinsight/insightface/tree/master/RetinaFace)
- [Retinaface (pytorch)](https://github.com/biubug6/Pytorch_Retinaface)
- [Ultra-Light-Fast-Generic-Face-Detector-1MB](https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB)
```
@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}
```
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
带有关键点检测的超轻量级人脸检测器.zip (75个子文件)
【CSDN:小正太浩二】下载说明.txt 1KB
Face-Detector-1MB-with-landmark-master
layers
__init__.py 48B
modules
__init__.py 68B
multibox_loss.py 5KB
functions
prior_box.py 1KB
.gitattributes 61B
weights
mobilenet0.25_Final.pth 1.71MB
slim_Final.pth 1.36MB
RBF_Final.pth 1.43MB
data
data_augment.py 7KB
__init__.py 112B
wider_face.py 3KB
config.py 1KB
LICENSE 1KB
utils
__init__.py 0B
nms
__init__.py 0B
py_cpu_nms.py 1KB
box_utils.py 13KB
timer.py 1KB
img
sample.jpg 460KB
1.jpg 942KB
widerface_evaluate
evaluation.py 9KB
ground_truth
wider_easy_val.mat 399KB
wider_face_val.mat 388KB
wider_hard_val.mat 414KB
wider_medium_val.mat 403KB
box_overlaps.pyx 2KB
setup.py 328B
README.md 507B
test_widerface.py 9KB
models
__init__.py 0B
retinaface.py 5KB
net_rfb.py 8KB
net.py 4KB
net_slim.py 4KB
detect.py 8KB
Face_Detector_ncnn
CMakeLists.txt 1KB
ncnn
include
ncnn
option.h 3KB
command.h 7KB
cpu.h 2KB
mat.h 45KB
platform.h 4KB
modelbin.h 2KB
pipeline.h 2KB
blob.h 1KB
benchmark.h 1KB
allocator.h 8KB
layer_type.h 942B
paramdict.h 2KB
gpu.h 6KB
layer_type_enum.h 1KB
opencv.h 6KB
net.h 6KB
layer.h 4KB
lib
libncnn.a 1.84MB
cmake
ncnn
ncnn-release.cmake 777B
ncnn.cmake 3KB
ncnnConfig.cmake 417B
tools
onnx2ncnn 233KB
FaceDetector.h 2KB
sample.jpg 85KB
FaceDetector.cpp 7KB
main.cpp 2KB
.idea
.name 7B
vcs.xml 183B
workspace.xml 13KB
misc.xml 240B
modules.xml 264B
1M_lib.iml 97B
model
face.bin 1.36MB
face.param 11KB
convert_to_onnx.py 4KB
train.py 6KB
README.md 5KB
calculate_paremeter_flop.py 2KB
共 75 条
- 1
资源评论
小正太浩二
- 粉丝: 194
- 资源: 5904
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功