insightface_pytorch主要做了以下几个方面的工作:
* 使用的相关算法
人脸检测: 由原来的retina改成了MTCNN,准确度差了不少
人脸对齐: 由原来的Dense U-Net改成了MTCNN
人脸识别: 当前可以支持mobilefacenet和resnet50-irse两种
* 提供了一个demo用于实现人脸实时识别
* 提供了数据转换模块,用于将MXNET数据格式的数据转换成pytorch支持的Image Dataforders
* 提供了模型训练模块
运行环境:
- python >= 3.6
- pytorch == 0.4.1
识别流程说明:
insightface_pytorch实现人脸识别包含两个步骤,第一步人脸检测和人脸对齐,第二步人脸识别
人脸检测(face detection)和人脸对齐(face alignment):使用基于MTCNN网络的开源项目mtcnn-pytorch,经过实测比retina要差很多
人脸识别(face recognition):人脸识别提供了多种模型mobilefacenet,retnet50-irse等网络的预训练模型和网络结构
预训练模型和准确率
IR-SE50 @ BaiduNetdisk, IR-SE50 @ Onedrive
LFW(%) | CFP-FF(%) | CFP-FP(%) | AgeDB-30(%) | calfw(%) | cplfw(%) | vgg2_fp(%) |
---|---|---|---|---|---|---|
0.9952 | 0.9962 | 0.9504 | 0.9622 | 0.9557 | 0.9107 | 0.9386 |
Mobilefacenet @ BaiduNetDisk, Mobilefacenet @ OneDrive
LFW(%) | CFP-FF(%) | CFP-FP(%) | AgeDB-30(%) | calfw(%) | cplfw(%) | vgg2_fp(%) |
---|---|---|---|---|---|---|
0.9918 | 0.9891 | 0.8986 | 0.9347 | 0.9402 | 0.866 | 0.9100 |
使用说明
1 Data Preparation
1.1 Prepare Facebank (For testing over camera or video)
Provide the face images your want to detect in the data/face_bank folder, and guarantee it have a structure like following:
data/facebank/
---> id1/
---> id1_1.jpg
---> id2/
---> id2_1.jpg
---> id3/
---> id3_1.jpg
---> id3_2.jpg
1.2 download the pretrained model to work_space/model
If more than 1 image appears in one folder, an average embedding will be calculated
1.3 Prepare Dataset ( For training)
download the refined dataset: (emore recommended)
- emore dataset @ BaiduDrive, emore dataset @ Dropbox
- More Dataset please refer to the original post
Note: If you use the refined MS1M dataset and the cropped VGG2 dataset, please cite the original papers.
-
after unzip the files to 'data' path, run :
python prepare_data.py
after the execution, you should find following structure:
faces_emore/
---> agedb_30
---> calfw
---> cfp_ff
---> cfp_fp
---> cfp_fp
---> cplfw
--->imgs
---> lfw
---> vgg2_fp
2 detect over camera:
2.1 download the desired weights to model folder:
2.2 to take a picture, run
python take_pic.py -n name
press q to take a picture, it will only capture 1 highest possibility face if more than 1 person appear in the camera
2.3 or you can put any preexisting photo into the facebank directory, the file structure is as following:
- facebank/
name1/
photo1.jpg
photo2.jpg
...
name2/
photo1.jpg
photo2.jpg
...
.....
if more than 1 image appears in the directory, average embedding will be calculated
2.4 to start
python face_verify.py
3 detect over video:
```
python infer_on_video.py -f [video file name] -s [save file name]
```
the video file should be inside the data/face_bank folder
- Video Detection Demo @Youtube
3.4 Training:
```
python train.py -b [batch_size] -lr [learning rate] -e [epochs]
# python train.py -net mobilefacenet -b 200 -w 4
```
对于工程的理解,应该是重点改进点在recognition上面。 这里需要知道人脸识别的几个模块。detection, alignment, verification ,identification/recognition . 所以,本工程的重点算法的改进在于recognition。而其它的模块,比如detection,可能就直接使用MTCNN。
对于工程的使用,主要是按照要求,组建好环境后,./recognition里 config.py里更改 dataset ,数据集, batchsize与gpu个数相关,然后去dataset-zoo下载了数据集后,开始训练,这样就生成了model ,model的生成位置也是在config.py里配置。在训练的过程中,也看到了verification.
如果你懒得去训练,直接使用pre-train model 。可以去文中讲的model-zoo里去下载; 认真点的,可以再使用verification.py
src/eval/verification.py验证其精度,不认真的,直接拿去使用吧。