Skip to content

caffe implementation of insightface's combined margin method

Notifications You must be signed in to change notification settings

hungsing92/CombinedMargin-caffe

 
 

Repository files navigation

Combined Margin (caffe)

中文版本README

Introduction

In this repo, a caffe implementation of Combined Margin is introduced.

This repo was inspired by insightface and arcface-caffe

Combined Margin was proposed by insightface as the improvement of Sphereface, AMSoftmax(CosineFace), and Additive Angular Margin which was proposed by insightface before.

This implementation follows the method in insightface, and do some modification. Mainly adding bounds for the logits after adding margin, so the logits value of ground truth won't get bigger after adding margin, instead of getting smaller which is our original purpose. And also add bound for the gradient.

Note that the combined margin in this implementation is rather hard without any tricks to help the converge while training.

According to insightface's experiments, the validation results of Combined Margin is better than the other methods mentioned above. see Verification Results On Combined Margin.

If you want to try other methods, please refer to insightface, arcface-caffe and AMSoftmax(CosineFace)

Installation

  1. Merge toadd.proto with caffe's caffe.proto, follow the instructions in toadd.proto.
  2. Place all the .hpp files in $CAFFE_ROOT/include/caffe/layers/, and all the .cpp and .cu files in $CAFFE_ROOT/src/caffe/layers/. Replace the original files if necessary.
  3. Go to $CAFFE_ROOT and make all. Maybe you need to do make clean first.
  4. Now you can use Combined Margin Layer in your caffe training. Here's an example.prototxt which is modified from AMSoftmax's prototxt. You can just change the LabelSpecificAddLayer into CombinedMarginLayer, and don't forget to change the layer parameters.

If you have any question, feel free to open an issue.

Anyone use the code, please site the original papers

update 2018-11-11 a resnet-36 model

Here's one ResNet-36 model (password: 6sgx), trained on ms-celeb-1m and asian-celeb provided by Deepglint. This model can get 99.75% on LFW. And on BLUFR, it gets 99.69% [email protected]%, 99.53% @FAR0.01%, 99.42% Top1@FAR1% . I didn't do other test.

update 2018-12-10 add training log

In res36-training-config folder is the training log, solver.prototxt and train.prototxt of ResNet-36 combined margin loss model training(password: y672). The training data is Trillionpairs by Deepglint. All faces are aligned to 112x96. This dataset provides 5-landmark information, so we don't need to do the detection and landmarks location.

About

caffe implementation of insightface's combined margin method

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 54.7%
  • Cuda 45.3%