This project is real-time face mask detection using webcam.
It performs face mask detection and classification on the live cam stream using the FasterRCNN model trained on the Kaggle dataset. Training and execution of CNN models is based on PyTorch. Model architecture, model training, pipeline, etc. were referenced from other great resources. The codes referenced are summarized below.
-
Capable of predicting muliple faces
-
3 types of results
🟢 with mask 🟡 mask weared incorrect 🔴 without mask
Team Members:
Hyuntaek Shin, Hwanseung Yoo, Jin Ryu, Seungun Jang
Now that we live in the era of COVID-19, the importance of wearing a mask in our daily life has already been emphasized several times. According to a paper in the international journal Lancet, wearing a mask correctly can reduce the risk of infection by more than 85%.
So, we devised a Face Mask Detector. Based on Livecam, it automatically detects whether people are wearing masks or not. Thus, it can utilize to warn people who do not wear the mask or who use the mask improperly to wear it correctly.
-
Kaggle Face Mask Detection dataset
- 853 pngs & xmls
- approximately 7:4:1 for with mask, without mask, mask weared incorrect
-
To resolve data imbalance between labels, we added additional images obtained by crawling.
- add 180 mask weared incorrect pngs & xmls
- Model architecture: FasterRCNN
- The Number of traing epochs : 25
- Learning Rate : 1e-2
- Optimization method : SGD
- Python 3.6+
- PyTorch 1.7.0+
- imutils
- necessary CUDA packages
-
Clone this repository
# Install git-lfs curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash sudo apt install git-lfs # Clone repository git clone https://github.com/AI-STACK-dev/Face-mask-detector.git cd Face-mask-detector
-
Donwload data from kaggle
- If you want to review data use
./src/data_review.ipynb
- If you want to review data use
-
Train your own model with
./src/train.ipynb
Or you can use trained model here -
Inference
python inference.py --model "/your/trained/model/path/model.pth"
- Long hair is recognized as a black mask
- Accuracy varies with distance
This project would not have been possible without following great resources.
This repository is licensed under the MIT License