breadbread1984 / deepid

deep face recognition algorithm
GNU General Public License v3.0
8 stars 9 forks source link

Tutorial on deepid

Introduction

This code is an implement of the face recognition algorithm introduced in paper Deep Learning Face Representation from Predicting 10,000 Classes.

Project Structure

train_model: training models and solvers for deepid feature extractor and face recognizer

deploy_model: deploy models for deepid feature extractor and face recognizer

model_values: trained model files

src: source codes

Building

make -j9

Training Feature Extractor

You can skip the training if you just want to do face recognition with this project because all pretrained deepid caffemodel files are given in model values directory

  1. request CASIA-webface dataset.

  2. crop patches from datasets as described in the paper

in root directory

./generate_training_sample -i <path/to/webface> -o <path/to/training patches for 60 models>
  1. convert patch samples into LMDB files

in root directory

./convert -i <path/to/training patches for 60 models> -o <path/to/lmdbs>
  1. train models

enter each generated lmdb directory for patches of one of 60 local facial areas and train with caffe.

caffe train -solver deepid_solver.prototxt -gpu all
  1. collect trained model files

in root directory

./move_training_results -i <path/to/lmdbs> -o model_values

Training Face Recognizer

  1. extract deepid features from webface faces

in root directory

./generate_training_samples  -i  <path/to/webface>  -o <path/to/lmdb of deepid feature>
  1. train face recognizer

train with caffe on the generated lmdb of deepid feature. My deepid code can only achieve 70% accuracy, trained and tested on webface.

Training Face Recognizer on dimension reduced (150d) feature vectors

  1. calculate principal vectors of deepid features and transform them into principal component subspaces
./transform  -i  <path/to/lmdb of deepid feature>  -o  <path/to/lmdb of dimension reduced deepid features>

This operation takes me around 3 weeks on my workstation to finish.

  1. train face recognizer

train with caffe on the generated lmdb of dimension reduced deepid feature. The accuracy is even lower, only 65% accuracy.

Demo of Face Recognition with deepid feature extractor + knn

  1. collect face pictures to recognizer

put (at least one) picture(s) for each person into individual directories and put all the directories into one parent directory.

  1. extract deepid features

in root directory

extract deepid feaures from faces

./main -m train -i <path/to/the parent directory>
  1. play with your webcam

recognize with knn from pictures captured from webcam

./main -m test -p  训练参数.dat