Face detection based on ChainerCV Faster-RCNN implementation Modified ChainerCV example to train on WIDER FACE dataset for face detection instead of on PASCAL VOC.
The original ChainerCV example code is: https://github.com/chainer/chainercv/tree/master/examples/faster_rcnn
UsageTested on Windows 10 (64 bit), Python 3.5.3 (installed by Anaconda)
This code depends on:
Library version:
Chainer 2.0.0
CuPy 1.0.0.1
ChainerCV 0.5.1
A pre-trained model is excluded from this repositiory. It will be downloaded automatically when you execute demo.py
. Otherwise, download it manually from the next link and put it on trained_model/snapshot_model.npz
.
DemoIf a path to pretorained model is not given, tained_model/snapshot_model.npz
is used. Since the pretrained model has large file size (484 MB), it is excluded from this repository. It will be downloaded automatically when demo.py
is executed.
python demo.py [--gpu <gpu>] [--pretrained_model <model_path>] <image>.jpg Train codeFirst, download the WIDER FACE dataset from the website: http://mmlab.ie.cuhk.edu.hk/projects/WIDERFace/
Download these files and extract:
Execute with specifing dataset directories and annotation files (.mat) for training and validation sets, such as:
python train.py --gpu=0 --train_data_dir="WIDER_train" --train_annotation="wider_face_split/wider_face_train.mat" --val_data_dir="WIDER_val" --val_annotation="wider_face_split/wider_face_val.mat" Or edit codes specifying dataset paths in train.py
and execute:
python train.py --gpu 0 test_dataset.pyShow ground truth and predicted result on the images from validation dataset. Requires OpenCV Python bindings to execute.
Edit test_detection.py
about dataset paths and run:
python test_detection.py --gpu 0 Esc key to exit. Any other keys to the next image.
eval.pyReturns average precision. (0.362059 for trained_model/snapshot_model.npz
)
python eval.py [--gpu <gpu>] [--pretrained_model <model_path>]