Skip to content

Creating a Face mask detector using CNN on Tensorflow/keras

License

Notifications You must be signed in to change notification settings

ombhatia99/Face-Mask-Detector

Repository files navigation

Face-Mask-Detector

GitHub PyPI - Python Version

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.

⭐ TechStack/framework used

📁 Dataset

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:

🔑 Prerequisites

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

💡 Working

  1. Open terminal. Go into the cloned project directory and type the following command:
$ python3 train_mask_detector.py --dataset dataset
  1. To detect face masks in an image type the following command:
$ python3 detect_mask_image.py --image images/pic1.jpeg
  1. To detect face masks in real-time video streams type the following command:
$ python3 detect_mask_video.py 

📑Streamlit app

Face Mask Detector webapp using Tensorflow & Streamlit

command

$ streamlit run app.py 

☑️Result

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

🌸 License

MIT © Om Bhatia

Releases

No releases published

Packages

No packages published