Home

Awesome

face-mask-detector

𝐑𝐞𝐚𝐥-𝐓𝐢𝐦𝐞 𝐅𝐚𝐜𝐞 𝐦𝐚𝐬𝐤 𝐝𝐞𝐭𝐞𝐜𝐭𝐢𝐨𝐧 𝐮𝐬𝐢𝐧𝐠 𝐝𝐞𝐞𝐩𝐥𝐞𝐚𝐫𝐧𝐢𝐧𝐠 𝐰𝐢𝐭𝐡 𝐀𝐥𝐞𝐫𝐭 𝐬𝐲𝐬𝐭𝐞𝐦 💻🔔

System Overview

It detects human faces with 𝐦𝐚𝐬𝐤 𝐨𝐫 𝐧𝐨-𝐦𝐚𝐬𝐤 even in crowd in real time with live count status and notifies user (officer) if danger.

<p align="center"> <img src="https://github.com/adityap27/face-mask-detector/blob/master/media/readme-airport.gif?raw=true"> </p>

System Modules:

  1. Deep Learning Model : I trained a YOLOv2,v3 and v4 on my own dataset and for YOLOv4 achieved 93.95% mAP on Test Set whereas YOLOv3 achieved 90% mAP on Test Set even though my test set contained realistic blur images, small + medium + large faces which represent the real world images of average quality.

  2. Alert System: It monitors the mask, no-mask counts and has 3 status :

    1. Safe : When all people are with mask.
    2. Warning : When atleast 1 person is without mask.
    3. Danger : ( + SMS Alert ) When some ratio of people are without mask.

Table of Contents

  1. Face-Mask Dataset
    1. Image Sources
    2. Image Annotation
    3. Dataset Description
  2. Deep Learning Models
    1. Training
    2. Model Performance
    3. Inference
      1. Detection on Image
      2. Detection on Video
      3. Detection on WebCam
  3. Alert System
  4. Suggestions to improve Performance
  5. References

Quick-Start

Step 1:

git clone https://github.com/adityap27/face-mask-detector.git

Then, Download weights. https://bit.ly/yolov4_mask_weights and put in yolov4-mask-detector folder

Step 2: Install requirements.

pip install opencv-python
pip install imutils

Step 3: Run yolov4 on webcam

python mask-detector-video.py -y yolov4-mask-detector -u 1

Optional: add -e 1 for Email notifications.

Face-Mask Dataset

1. Image Sources

2. Image Annotation

3. Dataset Description

SetNumber of imagesObjects with maskObjects without mask
Training Set7003047868
Validation Set10027849
Test Set120503156
Total92038281073

Deep Learning Models

1. Training

./darknet detector train obj.data yolo3.cfg darknet53.conv.74

YOLOv2 Training details

YOLOv3 Training details

YOLOv4 Training details

2. Model Performance

ModelTraining SetValidation SetTest SetFPS
YOLOv283.83%74.50%78.95%45 FPS
YOLOv399.75%87.16%90.18%23 FPS
YOLOv499.65%88.38%93.95%22 FPS

3. Inference

3.1 Detection on Image

3.2 Detection on Video

<p align="center"> <img src="https://github.com/adityap27/face-mask-detector/blob/master/media/readme-airport.gif?raw=true"> </p>

3.3 Detection on WebCam

<p align="center"> <img src="https://github.com/adityap27/face-mask-detector/blob/master/media/readme-webcam.gif?raw=true"> </p>

Note

Alert System

<p align="center"> <img src="https://github.com/adityap27/face-mask-detector/blob/master/media/readme-sms.jpg?raw=true"> </p>

Suggestions to improve Performance

References