Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/farhansadaf/face-mask-detection
Real-time face mask detection.
https://github.com/farhansadaf/face-mask-detection
computer-vision haarcascade-frontalface keras mtcnn-face-detection
Last synced: about 2 months ago
JSON representation
Real-time face mask detection.
- Host: GitHub
- URL: https://github.com/farhansadaf/face-mask-detection
- Owner: FarhanSadaf
- License: mit
- Created: 2020-08-23T16:19:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-31T14:22:55.000Z (almost 4 years ago)
- Last Synced: 2024-01-20T20:23:35.004Z (12 months ago)
- Topics: computer-vision, haarcascade-frontalface, keras, mtcnn-face-detection
- Language: Jupyter Notebook
- Homepage:
- Size: 3.06 MB
- Stars: 15
- Watchers: 2
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Real-time Face Mask Detection
## Overview
Face masks help reduce the transmission of SARS-CoV-2 by interfering with the spread of virus-laden droplets ejected from the nose and mouth.
Wearing face mask is one of the precautionary steps an individual can take in order to lessen the spread of COVID-19.
In this simple project, a video camera detects if an individual is wearing a face mask or not in real-time.
The detection steps looks somewhat like this:## Quickstart the project
1. Download the code in `ZIP` or open with `GitHub Desktop` or `git clone https://github.com/FarhanSadaf/face-mask-detection.git`. If you face issues downloading weight file, you can download from this google drive link.
2. Install required python dependencies into your python environment / virtual environment using `pip install -r requirements.txt`.
3. Run `script-1.py` for real-time detection using webcam. If detection isn't to your liking, try running `script-2.py`.## Dataset
The dataset used to train the face-mask detection model taken from here.This dataset contains 853 images belonging to the 3 classes, as well as their bounding boxes in the PASCAL VOC format.
The classes are:
- With mask
- Without mask
- Mask worn incorrectlyThough the dataset is pretty imbalanced with most of the data belonging to `With mask` class, it works pertty well detecting `With mask` and `Without mask` classes.
But more data for `Mask worn incorrectly` class is needed in order to detect this class properly.## Workflow
1. Data preprocessing :
All images have their bounding boxes in the PASCAL VOC format and their info saved in `XML` format in `annotaions` directory.
Only the region bounded by bounding box taken as input and their respective labels taken as output.2. Training mask detector model :
Transfer learning was used to train the inputs. The classifier model was built with InceptionV3 neural network architecture.
After training for 20 epochs, accuracy on test set was 96.81%.3. Detecting face mask in real-time :
First task was to detect faces from each frame of the video.
At first I used Haarcascade classifer from OpenCV for face detection. Average FPS I got while running on my machine was around 16.
But face detection wasn't that accurate. This classifer struggled detecting faces with mask. In low-light condition it struggled the most.
Then I tried MTCNN for face detection.
This algorithm performed great detecting faces, even in the low light. But while running on my machine, the average FPS I got was about 1.4.
Which is pretty slow comparing with haarcascade classifier.## Results
Input
Output
## Links and References
- Face Mask Detection dataset: https://www.kaggle.com/andrewmvd/face-mask-detection
- InceptionV3: https://www.tensorflow.org/api_docs/python/tf/keras/applications/InceptionV3
- Face Detection using Haar Cascades: https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html
- How to Perform Face Detection with Deep Learning: https://machinelearningmastery.com/how-to-perform-face-detection-with-classical-and-deep-learning-methods-in-python-with-keras/
- GitHub MTCNN: https://github.com/ipazc/mtcnn## Licensing
The code in this project is licensed under [MIT License](LICENSE).