In this project I trained, evaluated, and used YOLOv7 on images and videos to detect faces and classify if they're wearing face masks or not, not only that, the model can tell if a face mask is not worn correctly.
The dataset contains 853 images belonging to 3 classes:
- with_mask
- without_mask
- mask_weared_incorrect
All preprocessing, training, evaluation, and inference code and details are provided in the notebook above (Face_Mask_Detection.ipynb)
To use the model on your own data, follow these steps:
- Download the trained model from here
- Clone YOLOv7 repository and install the requirements
git clone https://github.com/WongKinYiu/yolov7.git
pip install -r yolov7/requirements.txt
- Run inference script and modify these parameters according to your data
--source : path to image/video
--weight : path to the trained model
--conf : confidence threshold, the trained model's optimal threshold is 0.26
--name : path to a folder to save results in
python ./yolov7/detect.py --source ./yolov7/data/test/images --weight ./runs/train/yolov7x_results8/weights/best.pt --conf 0.26 --name test_images