SafeGuard-CV is a real-time computer vision system that detects missing PPE (helmets) on construction sites using a fine-tuned YOLOv8s model, optimized for edge deployment via ONNX FP16 quantization.
Construction sites are high-risk environments where workers often skip wearing safety helmets. SafeGuard-CV automatically detects PPE violations in real-time using a camera feed, enabling instant safety alerts.
SafeGuard-CV/
├── safeguard-cv(finetuning).ipynb # Model training notebook (Kaggle)
├── safeguard-cv(validation).ipynb # Model validation notebook (Kaggle)
├── live_inference.py # Real-time inference script
└── README.md
- Source: Hardhat Detection by Michael — Roboflow Universe
- Images: 19,800
- Classes: Helmet, No-Helmet, Person
- Split: Train / Validation / Test
- Model: YOLOv8s
- Epochs: 25
- Batch Size: 16
| Class | mAP50 | mAP50-95 |
|---|---|---|
| All | 0.572 | 0.289 |
| Helmet | 0.665 | 0.334 |
| No-Helmet | 0.582 | 0.266 |
| Person | 0.471 | 0.267 |
- Format: ONNX
- Quantization: FP16
- Command:
yolo export model=best.pt format=onnx half=True| Metric | FP32 (Base) | FP16 ONNX (Edge) | Difference |
|---|---|---|---|
| Model Size | 21.5 MB | 21.4 MB | -0.1 MB |
| mAP50 | 0.572 | 0.570 | -0.002 |
| mAP50-95 | 0.289 | 0.289 | 0 |
| Accuracy Drop | - | 0.02% | Negligible loss |
| Avg FPS (RTX 3050) | 24.5 FPS | 36.7 FPS | +12 FPS |
The live_inference.py script loads the base model and edge model, and runs real-time inference on a video with the following overlays:
- Bounding boxes with class labels and confidence scores
- Live Inference FPS (excluding rendering time)
- Preprocessing latency (ms)
- Postprocessing / NMS latency (ms)
| Model | Format | Size | Link |
|---|---|---|---|
| best_fp32.pt | PyTorch FP32 | 21.5 MB | Download |
| best_fp16.onnx | ONNX FP16 | 21.4 MB | Download |
- Python 3.11.9
- YOLOv8s (Ultralytics)
- ONNX Runtime
- OpenCV
- Roboflow
- Kaggle (Tesla T4 GPU)
# Install dependencies
pip install ultralytics opencv-python numpy
# Run with edge model
python live_inference.py- Fine-tuned YOLOv8s on 19,800 construction-site images.
- Evaluated FP32 and FP16 ONNX deployments for edge inference.
- Built a real-time PPE compliance monitoring pipeline using OpenCV and ONNX Runtime.