开源人脸识别项目insightface_pytorch

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 @ BaiduNetdiskIR-SE50 @ Onedrive

LFW(%)CFP-FF(%)CFP-FP(%)AgeDB-30(%)calfw(%)cplfw(%)vgg2_fp(%)
0.99520.99620.95040.96220.95570.91070.9386

Mobilefacenet @ BaiduNetDiskMobilefacenet @ OneDrive

LFW(%)CFP-FF(%)CFP-FP(%)AgeDB-30(%)calfw(%)cplfw(%)vgg2_fp(%)
0.99180.98910.89860.93470.94020.8660.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)

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

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验证其精度,不认真的,直接拿去使用吧。

  • 2
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值