Due to the seen pandemic Covid-19 in the past years we got to know how wearing masks beccame important hence this system can therefore be used in real-time applications which require face-mask detection for safety purposes due to the outbreak . This project can be integrated with embedded systems for application in airports, railway stations, offices, schools, and public places to ensure that public safety guidelines are followed.
The dataset used can be downloaded here - Click to Download
This dataset consists of ~12k images belonging to three classes:
- Train
- Test
- Validation
All the dependencies and required libraries are included in the file requirements.txt
See here
- Clone the repo
$ git clone https://github.com/Sudhanshu21xx/Face-Mask-Detection.git
-
Open the repo in notebook
-
Now, run the following command in your notebook to install the libraries required
$ pip3 install -r requirements.txt
-
Download the dataset.
-
Change the directory main_dir in the Facemask_model.ipynb and run it:
import os
main_dir ='New Masks Dataset'
train_dir = os.path.join(main_dir,'Train')
test_dir = os.path.join(main_dir,'Test')
valid_dir = os.path.join(main_dir,'Validation')
train_mask_dir = os.path.join(train_dir,'Mask')
train_nomask_dir = os.path.join(train_dir,'Non Mask')
- Run the Facemaskdetection(open_cv).ipynb (you can also change the videocapture to livecapture)
cap = cv2.VideoCapture('video.mp4')
#cap = cv2.VideoCapture(0)