Home

Awesome

Face detection based on Darknet and Wider Face dataset

This project aims to realise face detection based on darknet and Wider Face dataset,incluing:

1. Clone the project.

First, clone this project using git: git clone https://github.com/zlmo/Face-Detection.git modify Makefile accordding to your device and make.

2. Prepare Wider Face dataset.

Then, we need to prepare the training set first. This includes downloading the dataset and transferring it to darknet style.

a. Download and extract Wider Face dataset

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

b. Transfer Wider Face to darknet style

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:

2. Train with yolov2, yolov3, yolov2-tiny-voc and etc.

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

3.A face detection method: A fast and lightweight method with feature fusion and multi-context for face detection

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: <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/resface/Figure3.png"/> <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/resface/Figure4.png"/>

./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

4. Evaluated on Wider Face validation set

We use toolkit from official website of Wider Face to evaluate the results, you need to install matlab and the Wider Face toolkit first.

5. And this is the qualitative result.

I write the paint.py to draw bounding boxes, red is the original annotations and green is the predicted bounding box. <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/blur/00.png"/> <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/blur/01.png"/> <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/blur/02.png"/> <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/expression/00.png"/> <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/expression/01.png"> <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/expression/02.png"> <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/small-faces/000.png"> <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/small-faces/001.png"> <img width="400" height="300" src="https://raw.github.com/zlmo/face_detection/master/detections/small-faces/002.png">