This repository contains the implementation of YOLOv11 fine-tuned for detecting Personal Protective Equipment (PPE) in construction sites. The model is trained using a Roboflow dataset containing 1,206 images annotated with five classes:
- 🟢
helmet - 🔴
no-helmet - 🟡
no-vest - 👷
person - 🦺
vest
The model has been hyperparameter tuned to achieve high precision and recall, making it ideal for real-time detection of safety compliance.
The dataset is sourced from Roboflow and consists of:
- Train set:
train/images - Validation set:
valid/images - Test set:
test/images - Number of Classes:
5 - Class Labels:
['helmet', 'no-helmet', 'no-vest', 'person', 'vest']
The dataset is configured in data.yaml as follows:
train: train/images
val: valid/images
test: test/images
nc: 5
names: ['helmet', 'no-helmet', 'no-vest', 'person', 'vest']git clone https://github.com/yourusername/YOLOv11-PPE-Detection.git
cd YOLOv11-PPE-DetectionMake sure you have Python 3.8+ and pip installed, then run:
pip install -r requirements.txtIf using a GPU, install
torchandtorchvisionaccordingly and requirements.txt assumes you already have torch installed.
- Extract or place the dataset inside
datasets/dataset/ - Ensure
data.yamlis correctly referenced in the scripts.
We have already place best.pt which a fine tuned model, but if you want re-train then: To train YOLOv11 from scratch or fine-tune on the PPE dataset, run(Ensure proper dataset configuration):
python train.pyThe training script:
- Loads the
YOLOv11-nanomodel (yolo11n.pt) - Performs hyperparameter tuning for 300 iterations
- Saves the best-trained weights in
runs/detect/train6/best.pt
Best Hyperparameters Found:
lr0: 0.00919
lrf: 0.01
momentum: 0.86723
weight_decay: 0.00041
warmup_epochs: 2.54
warmup_momentum: 0.731
box: 0.198
cls: 0.427
dfl: 1.23
mosaic: 0.607
fliplr: 0.499The best trained model was evaluated, and the following results were obtained:
Key Metrics:
mAP@0.5: 0.887mAP@0.5:0.95: 0.504Precision: 0.94 (forhelmet)Recall: 0.80 (forhelmet)
A Flask-based API is provided in main.py for real-time video inference.
python main.pyOpen a browser and visit:
http://127.0.0.1:5000/
Upload a video file from directory and Start Predictions
- The model can be further improved using data augmentation.
- Future improvements include model pruning for edge device deployment.







