Detecting facemasks using SSD and CNN
In this project, a face mask detection model is proposed that can classify people not wearing masks in a live video feed. The system can be deployed in a network of surveillance cameras and predictions from the model can be used to notify concerned authorities in case of mask mandate violation. The model implements a deep learning architecture that has been trained on a dataset containing images of people with and without masks along with bounding box coordinates for every face present in each image. The trained model achieved 95.04% accuracy on previously unseen test data. Keywords: Computer vision, deep learning, face mask detection, SSD
Caffe Face Detector (OpenCV Pre-trained Model)
Following packages should be installed:
- OpenCV-
pip install opencv-python
- Keras-
pip install keras
- NumPy-
pip install numpy
- MatPlotLib-
pip install matplotlib
- TensorFlow-
pip install tensorflow
Download the CNN model from given link and chnage the value of variable 'saved_model_path' in predict.py to the absolute path of the downloaded file.
Code realted to loading model, preprocessing, architecture is in
milestone3.ipynb
or
milestone3.py
predict.py [options] absolute/path/to/file
Where options
can be:
photo
to predict correctly worn fask masks in a photovideo
to predict correctly worn fask masks in a videolive
to predict correctly worn fask masks in a live feed through camera (here absolute/path/to/file is '0' for webcam and '1' for external camera)
For example:
python predict.py live 0
python predict.py video D:/video2.mp4
python test.py image D:/test3.jpeg
Test Loss for Model: 0.1662766933441162
Test Accuracy for Model: 0.9408695697784424