/Face-Mask-Detection

Using OpenCV, tensorflow/keras, computer vision, deep learing and Streamlit. Make it react

Primary LanguagePythonMIT LicenseMIT

Face Mask Detection


Face Mask Detection system built with OpenCV, Keras/TensorFlow using Deep Learning and Computer Vision concepts in order to detect face masks in static images and static videos. Also it is as well as in real-time video streams.


                              

πŸ‘‰ Which Tech & framework used ?


πŸ”₯ What is Streamlit?

Streamlit is an open-source Python library that makes it easy to build beautiful custom web-apps for machine learning and data science. To use it, just pip install streamlit , then import it, write a couple lines of code, and run your script with streamlit run [filename]


🌈 Introduction

In the present scenario due to Covid-19, there is no efficient face mask detection applications which are now in high demand for transportation means, densely populated areas, residential districts, large-scale manufacturers and other enterprises to ensure safety. Also, the absence of large datasets of β€˜with_mask’ images has made this task more cumbersome and challenging.


⚑️ Project Demo

  • Static Image

image


  • Static Video

video


  • Realtime - Webcam

webcam


πŸ“ Dataset

The dataset used can be downloaded here - Click to Download

This dataset consists of 3835 images belonging to two classes:

  • with_mask: 1916 images
  • without_mask: 1919 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 See here

Also, If you want to upload to the web, you need to download OpenH264. Link βœ… (https://https://github.com/cisco/openh264)

After download openh264 dll, move it into python library.

openh264


πŸš€ How to Install

  1. Clone the repo
$ git clone https://github.com/Hott-J/Face-Mask-Detection.git
  1. Change your directory to the cloned repo and create a Python virtual environment named 'test'
$ mkvirtualenv test
  1. Install the libraries required
$ pip3 install -r requirements.txt / pip install -r requirements.txt

πŸ’₯ How to Run

  1. Go into the cloned project directory folder and type the following command:
$ python3 train_mask_detector.py --dataset dataset
  1. To detect face masks in a static image, type the following command:
$ python3 detect_mask_image.py --image images/pic1.jpeg
  1. To detect face masks in a static video streams, type the following command:
$ python3 detect_mask_video.py 

🍭 Results

This Model gave 93% accuracy for Face Mask Detection after training via tensorflow-gpu==2.0.0

We got the following accuracy/loss training curve plot


🐢 How to Run in Streamlit Webapp

  1. Go into the cloned project directory folder and type the following command:
$ streamlit run app.py 

☘️ Finish!

Feel free to mail me for any query! Thank you ❀️