Coder Social home page Coder Social logo

dreadlord1984 / additive-margin-softmax Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joker316701882/additive-margin-softmax

0.0 3.0 0.0 2.51 MB

This is the implementation of paper <Additive Margin Softmax for Face Verification>

Python 29.10% Jupyter Notebook 70.90%

additive-margin-softmax's Introduction

Additive-Margin-Softmax

This is the implementation of paper <Additive Margin Softmax for Face Verification>

Training logic is highly inspired by Sandberg's Facenet, check it if you are interested.

model structure can be found at ./models/resface.py and loss head can be found at AM-softmax.py

Usage

Step1: Align Dataset

See folder "align", this totally forked from insightface. The default image size is (112,96), in this repository, all trained faces share same size (112,96). Use align code to align your train data and validation data (like lfw) first. You can use align_lfw.py to align both training set and lfw, don't worry about others like align_insight, align_dlib.

python align_lfw.py --input-dir [train data dir] --output-dir [aligned output dir]

Step2: Train AM-softmax

Read parse_arguments() function carefully to confiure parameters. If you are new in face recognition, after aligning dataset, simply run this code, the default settings will help you solve the rest.

python train.py --data_dir [aligned train data] --random_flip --learning_rate -1 --learning_rate_schedule_file ./data/learning_rate_AM_softmax.txt --lfw_dir [aligned lfw data] --keep_probability 0.8 --weight_decay 5e-4

Also watch out that acc on lfw is not from cross validation. Read source code for more detail. Thanks Sandberg again for his extraordinary code.

News

Date Update
2018-02-11 Currently it only reaches 97.6%. There might be some bugs, or some irregular preprocessings, when it reaches > 99%, detail configuration will be posted here.
2018-02-14 Now acc on lfw reaches 99.3% with only use resface36 and flipped-concatenate validation.
2018-02-15 After fixing bugs in training code, finally resface20 can reach 99.33% which only took 4 hours to converge. Notice:This model is trained on vggface2 without removing overlaps between vggface2 and lfw, so the performance is little higher than reported in orginal paper 98.98%(m=0.35) which trained on casia whose overlaps with lfw are removed.
2018-02-17 Using L-Resnet50E-IR which was proposed in this paper can reach 99.42%. Also I noticed that alignment method is crucial to accuracy. The quality of alignment algorithm might be the bottleneck of modern face recognition system.
2018โ€‘02โ€‘28 Just for fun, I tried m=0.2 with Resface20, acc on lfw reaches 99.47%. All experimens that I've done used AdamOptimizer without weight decay, SGD(with/without momentum) or RMSProp actually performed really bad in my experiments. My assumption is the difference of implementation of optimizer inside different frameworks (e.g. caffe and tf).
2018-03-05 Add training logic and align code.
2018-04-17 Fix bugs in evaluation code. Upload new/deeper model "LRenet50E_IR" proposed in insightface which performs better than resface20 and 36.
2018-08-29 Recently I revisiting this code and found that "weight_decay" settings for last fc layer is wrong, which lead to previous weird experiment conclusion. Now it's been fixed. And to follow standard evaluation protocal on lfw, evaluation code has been modified. The latest experiment result is updated here: Resface20(bn) + vggface2 + weight_decay5e-4 + batch_size256 + momentum achieves 0.995+-0.003 on lfw. Further more, with this code, it's easy to use some deeper models to achieve 99.7%+ on lfw. One big problem of this code is that it will load the name list of all images in cache at the begining, which will take very huge memory space. Also current dataset are composed of so small image files which will lead to low efficiency when load and transmit them. Thus tfrecord is recommanded to speed up training process.

lfw accuracy

Adam w/o weight_decay: img

Momemtum with weight_decay: See ./tfboard/resface20_mom_weightdecay.png

My Chinese blog about Face Recognition system

https://xraft.github.io/2018/03/21/FaceRecognition/
It includes the experimental details of this repo. Welcome and share your precious advice!

additive-margin-softmax's People

Contributors

joker316701882 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.