During the pandemic COVID-19, the World Health Organization (WHO) advised the use of masks as part of a comprehensive package of prevention and control measures to limit the spread of this virus.This project is focused on Real time face mask detection algorithm using machine learning with Python.
- Tensorflow
- Keras
- OpenCV
- numpy
To run this project, install the libraries locally using pip:
pip install tensorflow
pip install numpy
pip install matplotlib
pip install opencv
Here we are customizing our dataset to make it perfect for our model. The images are resized and augmented using imagedatagenerator and stored separately for train and validation.
Now after creating sets for training and validation next step is to build the model.The model is built using convolutional neural networks(CNN), Maxpooling layers and Dense layers along with activation functions Relu and sigmoid.
After model is created it needs to be compiled.For compilation the loss function used is categorical crossentropy,optimizer used is Adam.
Now its time to train our model with the images in train set. The model is trained with train set, validation set and checkpoints to save after completing 100 steps in each epoch.Once the training is complete the model is saved in .h5 format.
Using opencv we can take input image through our webcam. Using cascade classifiers in opencv we can fetch the face area and use our trained model to predict whether the person is wearing face-mask or not.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement" or "feature". Don't forget to give the project a star!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request