Home

Awesome

FaceMaskDetection

中文版 | English version

We open source all the popular deep learning frameworks' model and inference code to do face mask detection.

** Detect faces and determine whether they are wearing mask. **

** First of all, we hope the people in the world defeat COVID-2019 as soon as possible. Stay strong, all the countries in the world.**

We deployed a web page, you can click the link to experience it. The page is writen by Tensorflow.js.

AIZOO face mask detection

Model structure

We used the structure of SSD. However, in order to make it run quickly in the browser, the backbone network is lite. The total model only has 1.01M parametes.

Input size of the model is 260x260, the backbone network only has 8 conv layers. The total model has only 24 layers with the location and classification layers counted.

SSD anchor configurtion is show bellow:

multibox layersfeature map sizeanchor sizeaspect ratio)
First33x330.04,0.0561,0.62,0.42
Second17x170.08,0.11
Third9x90.16,0.221,0.62,0.42
Forth5x50.32,0.451,0.62,0.42
Fifth3x30.64,0.721,0.62,0.42

How to run

opencv

python opencv_dnn_infer.py  --img-path /path/to/your/img

paddle

on image:

python paddle_infer.py  --img-path /path/to/your/img

pytorch

on image:

python pytorch_infer.py  --img-path /path/to/your/img

on video:

python pytorch_infer.py --img-mode 0 --video-path /path/to/video  
# If you want to run with camera video, set  video_path to be 0
python pytorch_infer.py --img-mode 0 --video-path 0

TensorFlow/Keras/MXNet/Caffe

The other four frameworks running method is similar to pytorch, just replace pytorchwith tensorflow, keras,caffemxnet, if you want to use tensorflow, just run:

python tensorflow_infer.py  --img-path /path/to/your/img

Attention,for caffe's inference ,we use permute layer,so that we should use caffe-ssd,you can use opencv-dnn to do the inference.

Appendix

Feedback

If you use wechat, you can follow us.

** If you use Wechat, scan the code to add me on wechat **

Model structure

We merge the BN to Conv layers in order to accelerate the inference speed.

Testset PR curve

Our demo page

aizoo.com face mask detection demo