Face detection with darknet on WIDER FACE
This project aims to realise face detection based on darknet and Wider Face dataset,incluing:
First, clone this project using git:
git clone https://github.com/zlmo/Face-Detection.git
modify Makefile accordding to your device and make.
Then, we need to prepare the training set first. This includes downloading the dataset and transferring it to darknet style.
Download link can be found here: http://mmlab.ie.cuhk.edu.hk/projects/WIDERFace/ WIDER_train.zip, WIDER_val.zip and wider_face_split.zip are needed at least.
Once downloading completed, extract WIDER_train.zip, WIDER_val.zip and wider_face_split.zip to '/darknet'
unzip WIDER_train.zip -d ./darknet
unzip WIDER_val.zip -d ./darknet
unzip wider_face_split.zip -d ./darknet
When we use Wider Face to train our networks, we need to transfer the dataset to darknet style. The official darknet project use Pascal VOC style, so we transfer Wider Face to Pascal VOC style. I have write the python file to transfer, just run it!
python widerface_label.py
This file will do the following things:
Once the dataset has been prepared okay, we can start to train the network for face detection. When use the official yolo-like networks for face detection, we need to do some modifications:
./darknet detector train cfg/widerface.data cfg/yolov2-tiny-voc.cfg darknet.conv.13
This is trained use yolov2-tiny-voc.cfg, and the pre-trained weights darknet.conv.13 can be found here in BaiduYun:
Link: https://pan.baidu.com/s/1QThdiQqAUFX6XYyFtTyF8Q Extraction code: j1fr
And some trained networks can be found here (These networks may have some little changes compare to original networks):
face_small_3
Link: https://pan.baidu.com/s/1WrYsByjLbjT1B6B-H_Y8sg Extraction code: sa4h
face_small_6
Link: https://pan.baidu.com/s/18a907k6z2ZqRofosgfB3lg Extraction code: q8d9
The cfg file of this network is resface_slim.cfg. This network is a fast lightweight face detection network with feature fusion and context,its mainly architecture includes:(1)taking resnet18 as backbone;(2)feature fusion adopted from FPN;(3)multi-context,adding both local context and global context to the feature maps, and the local context is added by a depthwise separable convolution way to reduce computation.The architecture and the cnotext module is shown below:
./darknet detector train cfg/widerface.cfg cfg/resface_slim.cfg resnet18.conv.25
There's a little difference from the figure, I modified the local context to make it faster. And the pre-trained weights of resface_slim can be found here: 链接: https://pan.baidu.com/s/1OUh8cJbRmEd1M3rvpph11Q 密码: f4r8
We use toolkit from official website of Wider Face to evaluate the results, you need to install matlab and the Wider Face toolkit first.
./darknet detector valid cfg/widerface.data cfg/face_small_context3.cfg ./backup/face_small_context3_final.weights
After validation, we will get a resulting .txt file under '/results':
comp4_det_test_aeroplane.txtpython valid_transfer.py
This will produce the results needed by Wider Face (the result format could refer to 'widerface_result') and thenI write the paint.py to draw bounding boxes, red is the original annotations and green is the predicted bounding box.