| title | Face-Mask-Detection-YOLOv5l | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| emoji | 😷 | ||||||||
| colorFrom | green | ||||||||
| colorTo | gray | ||||||||
| sdk | gradio | ||||||||
| app_file | app.py | ||||||||
| pinned | true | ||||||||
| license | mit | ||||||||
| tags |
|
Face-Mask-Detection-YOLOv5l is an AI-powered app that detects whether people are wearing masks correctly, incorrectly, or not at all — using a fine-tuned YOLOv5l model.
📷 Upload an image, paste from clipboard, or take a webcam snapshot
The app returns bounding boxes and labels on detected faces:
with_maskwithout_maskmask_weared_incorrect
Deployed on Hugging Face Spaces:
- Model: YOLOv5l (v6.2)
- Classes:
with_mask,without_mask,mask_weared_incorrect - Input Size: 640×640
- Dataset: Kaggle Face Mask Detection
- Training: 50 epochs, manual
.state_dict()loading for PyTorch 2.6+ compatibility
Model was fine-tuned on Kaggle.
fine-tuning-yolov5l-for-face-mask-detection
Includes:
- YOLOv5l setup (v6.2 locked)
- Custom YAML config for 3 classes
- Exported
best_state_dict.ptfor deployment - Validated mAP:
0.879, P:0.896, R:0.817
- Detects 3 face mask statuses
- Upload image, webcam snapshot, or clipboard paste
- Adjustable confidence threshold
- Annotated output with bounding boxes and labels
- Lightweight and fast — runs in browser via Hugging Face
face-mask-detection-yolov5l/
├── yolov5/ # Cloned YOLOv5 repo (v6.2)
├── app.py # Gradio interface logic
├── inference\_utils.py # Model loading + NMS + annotation
├── model/
│ └── best\_state\_dict.pt # Trained YOLOv5l model weights
├── examples/ # Sample test images
├── requirements.txt
└── README.md| Input Image | Annotated Output |
|---|---|
![]() |
![]() |
To run locally:
git clone https://github.com/McKlay/face-mask-detection-yolov5l
cd face-mask-detection-yolov5l
pip install -r requirements.txt
python app.pytorch
opencv-python
numpy
Pillow
gradio
torchvision
matplotlib
seabornDeveloped by Clay Mark Sarte
Built with PyTorch and Gradio
Deployed to Hugging Face Spaces
This tool is for demonstration and educational use only. It is not intended for real-world medical or security deployment.

