Face Mask Detector built with OpenCV, TensorFlow/Keras using Deep Learning CNN and Computer Vision concepts in order to detect face masks in static images as well as in real-time video streams.
The dataset used can be downloaded here - Click to Download
This dataset consists of 4095 images belonging to two classes:
- with_mask: 2165 images
- without_mask: 1930 images
The images used were real images of faces wearing masks. The images were collected from the following sources:
- Bing Search API (See Python script)
- Kaggle datasets
- RMFD dataset (See here)(medium article link)
All the dependencies and required libraries are included in the file requirements.txt
Run the following command in your Terminal/Command Prompt to install the libraries required
$ pip3 install -r requirements.txt
- Open terminal. Go into the cloned project directory and type the following command:
$ python3 train_mask_detector.py --dataset dataset
- To detect face masks in an image type the following command:
$ python3 detect_mask_image.py --image images/pic1.jpeg
- To detect face masks in real-time video streams type the following command:
$ python3 detect_mask_video.py
Face Mask Detector webapp using Tensorflow & Streamlit
command
$ streamlit run app.py
Hyperparameter: - batch size: 32 - Learing rate: 0.0001 - Input size: 64x64x3
The Pre-trained models used can be downloaded here - Click to Download
Model result
Model | Test Accuracy | Size | Params | Memory consumption |
---|---|---|---|---|
CNN | 87.67% | 27.1MB | 2,203,557 | 72.58 MB |
VGG16 | 93.08% | 62.4MB | 288,357 | 18.06 MB |
MobileNetV2 (fine tune) | 97.33% | 20.8MB | 1,094,373 | 226.67 MB |
Xception | 98.33% | 96.6MB | 1,074,789 | 368.18 MB |
MIT © Om Bhatia