Implementation based on the paper Li et al., “A Convolutional Neural Network Cascade for Face Detection, ” 2015 CVPR
- Multi-resolution is not used for simplicity, you can add them in the .prototxt files under CNN_face_detection_models to do so.
- 12-net is turned into fully convolutional neural network to reduce computation.
- I took out the normalization layers out of the deploy.prototxt files in 48-net and 48-calibration-net, because of convenience for me implementing them in hardware, you can just simply at them back as in the corresponding train_val.prototxt files.
Detection scripts are stored under CNN_face_detection/face_detection directory, and models can be found in CNN_face_detection_models repository.
For testing single image, use script face_cascade_fullconv_single_crop_single_image.py
For benchmarking on FDDB, use script face_cascade_fullconv_fddb.py
If you're not familiar with caffe's flow yet, dennis-chen's reply here gives a great picture.
- You should first download all faces from the AFLW dataset, and at least 3000 images without any faces (negative images).
- Create negative patches by running face_preprocess_10kUS/create_negative.py with data_base_dir modified to the folder containing the negative images.
- Create positive patches by running face_preprocess_10kUS/aflw.py
- Run face_preprocess_10kUS/shuffle_write_positives.py and face_preprocess_10kUS/shuffle_write_negatives.py to shuffle and write position and labels of images to file.
- Run face_preprocess_10kUS/write_train_val.py to create train.txt, val.txt and move images to corresponding folders as caffe requires.
- Use scripts in CNN_face_detection_models/create_lmdb_scripts/ to create lmdb files as caffe requires.
- Start training by using such commands in terminal.
./build/tools/caffe train --solver=models/face_12c/solver.prototxt
24 net and 48 net can be created in a similar way, however negative images shoud be created by running face_preprocess_10kUS/create_negative_24c.py and face_preprocess_10kUS/create_negative_48c.py
Calibration nets are also trained similarly, scripts can be found in face_calibration/