Home

Awesome

2019.07.14
Currently, I have graduated from campus and doing another kind of job. So this project may not be updated again.

Face_Pytorch

The implementation of popular face recognition algorithms in pytorch framework, including arcface, cosface and sphereface and so on.

All codes are evaluated on Pytorch 0.4.0 with Python 3.6, Ubuntu 16.04.10, CUDA 9.1 and CUDNN 7.1. Partially evaluated on Pytorch 1.0.

Data Preparation

For CNN training, I use CASIA-WebFace and Cleaned MS-Celeb-1M, aligned by MTCNN with the size of 112x112. For performance testing, I report the results on LFW, AgeDB-30, CFP-FP, MegaFace rank1 identification and verification.

For AgeDB-30 and CFP-FP, the aligned images and evaluation images pairs are restored from the mxnet binary file provided by insightface, tools are available in this repository. You should install a mxnet-cpu first for the image parsing, just do ' pip install mxnet ' is ok.
LFW @ BaiduNetdisk, AgeDB-30 @ BaiduNetdisk, CFP_FP @ BaiduNetdisk

Results

MobileFaceNet: Struture described in MobileFaceNet
ResNet50: Original resnet structure
ResNet50-IR: CNN described in ArcFace paper
SEResNet50-IR: CNN described in ArcFace paper

Verification results on LFW, AgeDB-30 and CFP_FP

Small Protocol: trained with CASIA-WebFace of data size: 453580/10575
Large Protocol: trained with DeepGlint MS-Celeb-1M of data size: 3923399/86876

Model TypeLossLFWAgeDB-30CFP-FPModel Sizeprotocol
MobileFaceNetArcFace99.2393.2694.344MBsmall
ResNet50-IRArcFace99.4294.4595.34170MBsmall
SEResNet50-IRArcFace99.4394.5095.43171MBsmall
MobileFaceNetArcFace99.5896.5792.904MBlarge
ResNet50-IRArcFace99.8298.0795.34170MBlarge
SEResNet50-IRArcFace99.8098.1395.60171MBlarge
ResNet100-IRArcFace99.8398.2896.41256MBlarge

There exists an odd result fact that when training under small protocol, CFP-FP performances better than AgeDB-30, while when training with large scale dataset, CFP-FP performances worse than AgeDB-30.

MegaFace rank 1 identifiaction accuracy and verfication@FPR=1e-6 results

Model TypeLossMF Acc.MF Ver.MF Acc.@RMF Ver.@RSIZEprotocol
MobileFaceNetArcFace69.1084.2381.1585.864MBsmall
ResNet50-IRArcFace74.3188.2387.4489.56170MBsmall
SEResNet50-IRArcFace74.3788.3288.3089.65171MBsmall
MobileFaceNetArcFace74.9588.7789.4791.034MBlarge
ResNet50-IRArcFace79.6196.0296.5896.78170MBlarge
SEResNet50-IRArcFace79.9196.1097.0197.60171MBlarge
ResNet100-IRArcFace80.4096.9497.6098.05256MBlarge

Usage

  1. Download the source code to your machine.
  2. Prepare the train dataset and train list, test dataset and test verification pairs.
  3. Set your own dataset path and any other parameters in train.py.
  4. Run train.py file, test accuracy will print into log file during training process.

  1. Every evaluate file can work independently for the model test process. just set your own args in the file.

Visualization

Visdom support for loss and accuracy during training process.
avatar

Softmax Loss vs Softmax_Center Loss. Left: softmax training set. Right: softmax + center loss training set.

<div align="center"> <img src="result/softmax.gif" alt="train" width="49.5%"> <img src="result/softmax_center.gif" alt="train" width="49.5%"> </div>

References

MuggleWang/CosFace_pytorch
Xiaoccer/MobileFaceNet_Pytorch
TreB1eN/InsightFace_Pytorch
deepinsight/insightface
KaiyangZhou/pytorch-center-loss
tengshaofeng/ResidualAttentionNetwork-pytorch

Todo

  1. Report the test results on DeepGlint Trillion Pairs Challenge.
  2. Add C++ api for fast deployment with pytorch 1.0.
  3. Train the ResNet100-based model.