This repo contains a Mask Detection system which is built with OpenCV, Keras, TensorFlow using Deep Learning and Computer Vision concepts in order to detect face masks in static images as well as in real-time video streams.
The face mask detector model is accurate, and based on MobileNetV2 architecture, it’s also computationally efficient which makes it easier to deploy the model to hardware and embedded systems like Arduino,Raspberry Pi etc.
This app can be used in real-time applications and can be integrated with embedded systems for application in railway stations, airports, schools, and public places to ensure safety in Covid-19.
This dataset consists of nearly 3800 images belonging to two labels:
- with_mask: 1900 images
- without_mask: 1900 images
The images used were real images of faces wearing masks. The images were collected from internet, web and kaggle.
- Clone the repo
$ git clone https://github.com/PraveenGNair/mask-detection.git
- Change your directory to the cloned repo and create a Python virtual environment named 'testEnv'
$ mkvirtualenv testEnv
- Now, run the following command in your Terminal/Command Prompt to install the libraries required
$ pip install -r requirements.txt
- Open terminal. Go into the cloned project directory and type the following command:
$ python train_mask_detector.py --dataset dataset
- Once the model training is completed, you would get a model file created. Now To detect face masks in an image type the following command:
$ python detect_mask_image.py --image images/pic1.jpeg
- To detect face masks in real-time video streams type the following command:
$ python detect_mask_video.py
The web app is hosted in heroku is a Streamlit app using Tensorflow & Streamlit. So to run web in local you can use below command
$ streamlit run app.py