YOLOv8 fine-tuned for Personal Protective Equipment (PPE) detection at industrial worksites. Backbone model for SafetyVision, an open-source AI workplace safety monitor.
Source du modèle
Description de la source
YOLOv8 fine-tuned for Personal Protective Equipment (PPE) detection at industrial worksites. Backbone model for SafetyVision, an open-source AI workplace safety monitor.
This repo hosts two versions:
Sources
1 sourceVérifié 27 sept.
Artefacts du modèle
6 artefactsv2/best_640.onnx
Extraits de sources
2 extraitsv2/.| Headline metric (v2, held-out test) | Value |
|---|---|
| Test [email protected] (imgsz 896) | 0.766 |
| Test [email protected] (imgsz 640) | 0.754 |
| Deployed ONNX [email protected] (imgsz 640) | 0.738 |
| Test [email protected]:0.95 (imgsz 896) | 0.487 |
| Validation [email protected] | 0.787 |
| Parameters | 11,130,615 (~11.1M) |
| FLOPs | 28.5 GFLOPs |
Honest note on the target. The Phase-2 goal was [email protected] ≥ 0.78 on the held-out test split. Validation cleared it (0.787); the held-out test came in at 0.766 (imgsz 896) — short of 0.78 by 0.014. We report the test number as the headline generalization figure rather than leading with the higher validation value. See Evaluation.
| Aspect | v1 (YOLOv8n) | v2 (YOLOv8s) |
|---|---|---|
| Backbone | nano | small |
| Parameters | ~3.0M | ~11.1M |
| Training images | 57,904 (1 dataset) | 80,304 (5 datasets merged + MD5 dedup) |
| Augmentation | ultralytics defaults | + Albumentations (CoarseDropout, MotionBlur, RandomGamma, CLAHE) + perspective |
| Epochs | 100 | 150 (cosine LR) |
| Train image size | 640 | 896 |
| Hardware | Kaggle 2× T4 (16GB) | GCP L4 (24GB), single 61.25 hr run |
| Test [email protected] | 0.701 | 0.766 (896) / 0.754 (640) |
| Test [email protected]:0.95 | 0.441 | (896) / 0.485 (640) |
Test-vs-test improvement: +6.5 [email protected] / +4.6 [email protected]:0.95 at imgsz 896 (+5.3 [email protected] at 640). Two failure-mode classes improved dramatically — see Failure modes.
13-class PPE detection covering hard hats, safety vests, goggles, gloves, masks, their "missing/no" violation counterparts, fall detection, fall-harness absence, and a Person class.
yolov8s.pt for v2, yolov8n.pt for v1| ID | Class | Type |
|---|---|---|
| 0 | Fall-Detected | Event |
| 1 | Gloves | PPE worn ✓ |
| 2 | Goggles | PPE worn ✓ |
| 3 | Hardhat | PPE worn ✓ |
| 4 | Mask | PPE worn ✓ |
| 5 | NO-Gloves | Violation ✗ |
| 6 | NO-Goggles | Violation ✗ |
| 7 | NO-Hardhat | Violation ✗ |
| 8 | NO-Mask | Violation ✗ |
| 9 | NO-Safety Vest |
Five Roboflow Universe datasets merged into one corpus, deduplicated by MD5 hash and remapped to the 13 canonical classes:
ppe-combined-9bprl-mmcaf (v1)hardhat-safetyvest (v1)fall-detection-ca3o8 (v4)safety_ppe (v1)construction-safety-gears-vcbdq (v1)| Split | Images |
|---|---|
| Train | 68,253 |
| Validation | 8,025 |
| Test (held-out) | 4,026 |
| Total (post-dedup) | 80,304 |
Stratified 85/10/5 split (~6.4 GB). Dataset selection deliberately favored side/back/occluded poses, low-light and high-glare scenes, and non-frontal workers to address v1's frontal bias.
PPE-Combined v1 — 57,904 images (41,922 train / 10,834 val / 5,148 test).
g2-standard-8, asia-southeast1-c)multi_scale=True OOMs at batch=24 on a 24GB L4 at peak image size; the marginal benefit isn't worth halving the batch / ~95 hr wall time for a fixed-resolution deployment)Ultralytics project (the ultralytics W&B callback hardcodes the project name and ignores WANDB_PROJECT).mlruns/, experiment 621501274199551492, run 0af3bb3c50b84db3ac376d7e63e558d8.9nctv2ai) has expired; v1 canonical metrics live in model/yolov8n-ppe-v1/results.csv in the repo.Honest numbers, no cherry-picking. The held-out test split (4,026 images, never seen during training/validation) is the canonical generalization measure.
| Measurement | [email protected] | [email protected]:0.95 | P | R |
|---|---|---|---|---|
.pt @ imgsz 896 (model ceiling) | 0.766 | 0.487 | 0.731 | 0.757 |
.pt @ imgsz 640 | 0.754 | 0.485 | 0.724 | 0.736 |
| ONNX @ imgsz 640 (deployed, Lambda) | 0.738 | 0.463 | 0.723 | 0.715 |
| Validation @ imgsz 896 | 0.787 | 0.504 | 0.755 | 0.778 |
The ~0.016 ONNX-vs-.pt gap at 640 is fp32 numerical drift through onnxslim/opset-20 (precision is unchanged, recall dips slightly at the detection threshold), not a broken export. The 640 ONNX ships on AWS Lambda (CPU budget); the 896 ONNX ships on Hugging Face Spaces (16GB RAM) for the full 0.766 ceiling.
| Class | Instances | P | R | [email protected] | [email protected]:0.95 |
|---|---|---|---|---|---|
| Fall-Detected | 765 | 0.886 | 0.937 | 0.959 | 0.704 |
| Hardhat | 5,589 | 0.888 | 0.912 | 0.937 | 0.608 |
| Goggles | 256 | 0.857 | 0.887 | 0.919 | 0.545 |
| Safety Vest | 1,015 | 0.816 | 0.831 | 0.892 | 0.648 |
| Person | 1,038 |
Confusion matrices and PR curves (640 and 896) are committed in docs/assets/eval/v2/.
YOLOv8n test [email protected] = 0.701, [email protected]:0.95 = 0.441. Full v1 per-class metrics and curves in model/yolov8n-ppe-v1/.
/tmp (cached for subsequent warm invocations on the same container).best_640.onnx 42.7 MB, best_896.onnx 42.8 MB (fp32, opset 20, onnxslim 0.1.94, no external-data sidecar)Per-violation results carry two attribution signals alongside the bounding boxes: a GradCAM heatmap and a SHAP pixel attribution. Both are surfaced in three places — the web UI tabs on the Upload result page, the API response (gradcam_b64 and shap_chart_b64), and embedded side-by-side in the downloadable PDF incident report alongside the annotated detection image, the OSHA citation, and the Gemini-generated incident narrative.
model.model[9]) is the only consistently usable GradCAM target identified during development on this model; targeting earlier or later layers produced noisier results in testing. Kept in the pipeline because the cases where it works clearly are exactly the ones that warrant visual confirmation; in diffuse scenes the SHAP attribution alongside it provides a useful complementary signal.shap.GradientExplainer against the YOLO classification head at 320×320 (host machine needs ≥11 GB RAM for the backward pass — relevant on WSL where the default 7.6 GB is insufficient). Rendered as a per-pixel attribution chart in the web UI and PDF report.Pre-screening tool to assist human workplace safety officers by surfacing likely PPE violations in images and short video clips for human review. Designed for construction sites, warehouses, manufacturing floors, and pre-shift safety walkthroughs.
Not a replacement for human judgment. Predictions must be reviewed by qualified safety personnel before any disciplinary, compliance, or insurance action.
Documented from training-data review and observed v2 test errors:
construction-safety-gears) mixes COVID-style face-mask close-ups into the industrial-mask class, adding domain noise. Mask precision in particular suffers (0.39).onnx · 42,7 MB · SHA-256 ea18ae903a56…0b35 · Hugging Face
--- license: agpl-3.0 language: - en library_name: ultralytics pipeline_tag: object-detection tags: - yolov8 - yolov8s - object-detection - ppe-detection - workplace-safety - computer-vision - onnx - albumentations - safety - osha --- # SafetyVision YOLOv8 — PPE Detection (v1 nano · v2 small) YOLOv8 fine-tuned for Personal Protective Equipment (PPE) detection at industrial worksites. Backbone model for [SafetyVision](https://github.com/ayushgupta07xx/SafetyVision), an open-source AI workplace safety monitor. This repo hosts **two versions**: - **v2 (current, production)** — YOLOv8s, trained on 80k images with Albumentations augmentation. Weights at `v2/`. - **v1 (original)** — YOLOv8n, trained on 58k images. Weights at the repo root, kept for reproducibility and the v1→v2 comparison. | Headline metric (v2, held-out test) | Value | |---|---| | **Test [email protected] (imgsz 896)** | **0.766** | | Test [email protected] (imgsz 640) | 0.754 | | Deployed ONNX [email protected] (imgsz 640) | 0.738 | | Test [email protected]:0.95 (imgsz 896) | 0.487 | | Validation [email protected] | 0.787 | | Parameters | 11,130,615 (~11.1M) | | FLOPs | 28.5 GFLOPs | > **Honest note on the target.** The Phase-2 goal was [email protected] ≥ 0.78 on the held-out **test** split. Validation cleared it (0.787); the held-out test came in at **0.766** (imgsz 896) — short of 0.78 by 0.014. We report the test number as the headline generalization figure rather than leading with the higher validation value. See [Evaluation](#evaluation). ## What's new in v2 (v1 → v2) | Aspect | v1 (YOLOv8n) | v2 (YOLOv8s) | |---|---|---| | Backbone | nano | small | | Parameters | ~3.0M | ~11.1M | | Training images | 57,904 (1 dataset) | 80,304 (5 datasets merged + MD5 dedup) | | Augmentation | ultralytics defaults | + Albumentations (CoarseDropout, MotionBlur, RandomGamma, CLAHE) + perspective | | Epochs | 100 | 150 (cosine LR) | | Train image size | 640 | 896 | | Hardware | Kaggle 2× T4 (16GB) | GCP L4 (24GB), single 61.25 hr run | | Test [email protected] | 0.701 | **0.766** (896) / 0.754 (640) | | Test [email protected]:0.95 | 0.441 | **0.487** (896) / 0.485 (640) | | Deployed weights | `best.onnx` (640) | `v2/best_640.onnx` + `v2/best_896.onnx` | Test-vs-test improvement: **+6.5 [email protected] / +4.6 [email protected]:0.95** at imgsz 896 (+5.3 [email protected] at 640). Two failure-mode classes improved dramatically — see [Failure modes](#failure-modes). ## Model description 13-class PPE detec...
Source context: 523 downloads · 3 likes · Pipeline object-detection · Library ultralytics · Repo ayushgupta7777/safetyvision-yolov8
| Deployed weights | best.onnx (640) | v2/best_640.onnx + v2/best_896.onnx |
| Violation ✗ |
| 10 | No_Harness | Violation ✗ |
| 11 | Person | Person detection |
| 12 | Safety Vest | PPE worn ✓ |
| 0.870 |
| 0.798 |
| 0.861 |
| 0.584 |
| No_Harness | 256 | 0.728 | 0.773 | 0.830 | 0.533 |
| Gloves | 669 | 0.810 | 0.677 | 0.786 | 0.423 |
| NO-Hardhat | 865 | 0.687 | 0.788 | 0.754 | 0.474 |
| NO-Gloves | 713 | 0.771 | 0.685 | 0.751 | 0.400 |
| NO-Goggles | 439 | 0.765 | 0.608 | 0.711 | 0.387 |
| NO-Mask | 115 | 0.559 | 0.694 | 0.598 | 0.430 |
| Mask | 143 | 0.387 | 0.825 | 0.575 | 0.376 |
| NO-Safety Vest | 217 | 0.478 | 0.431 | 0.386 | 0.224 |
| all | 12,080 | 0.731 | 0.757 | 0.766 | 0.487 |