Work · Case file 04 · Course project, deployed web app · 2025

Beyond Helmets: PPE Compliance

5 min readJump to proofJump to limits

At a glance

Result
Held-out test mAP50 0.47 on 255 images (validation during training 0.62 to 0.64). At the app's 0.5 threshold it finds 29.5 percent of labelled items; pose landmarks confirm each item is worn.
Problem
A detector that only finds a helmet somewhere in the frame can pass a worker who is carrying it.
My role
System architecture and full-stack development in a team of five.Team: Zulfaqar Hafez, Daniel Chua, Shawn Lim, Royston Teo and Tan Chun Yuan (Max). Max, Shawn and Daniel trained the models, and Royston worked on full-stack with me. The README lists these roles.
Stack
Ultralytics YOLOv8 · MediaPipe Pose · FastAPI 0.110 · Supabase

Proof

What try, see and check mean

On this pageThe problem

The problem

Manual PPE inspection on hazardous sites is slow, inconsistent and hard to scale. A detector that only finds a helmet somewhere in the frame can pass a worker who is carrying it, and a fixed rule set cannot follow sites whose requirements differ from zone to zone.

The idea. Detect gear with YOLOv8, then cross-check each detection against MediaPipe's 33 pose landmarks so PPE only counts when it sits at the right body location, and let supervisors toggle which items are required without retraining.

Fig. 01 · Detect, then prove it is worn

  1. Camera frame
  2. YOLOv8 detectorhelmets, vests and gloves, and each one missing
  3. MediaPipe pose33 body landmarks
  4. Pose-aware checkis the helmet on the head, the vest on the torso
  5. Requirement toggleswhat this site requires, no retraining
  6. Compliance verdictFastAPI, logged to Supabase
A frame flows left to right: YOLOv8n finds people, the custom YOLOv8 PPE model finds gear, MediaPipe places 33 pose landmarks, and the Dual Validation Engine (Euclidean distance plus landmark matching) decides whether each item sits on the right body part. The Compliance Evaluator then applies the sidebar requirement toggles, so the same detection can pass or fail depending on what the site requires.

How it scores on held-out images

The deployed checkpoint (best_deep.pt) on the test split it never trained on: 255 images, 1,237 labelled boxes, run on CPU on 11 Nov 2026. AP50 is per class over all confidences; recall is at the 0.5 threshold the app uses.

Per-class results of the deployed model on the held-out test split
ClassTest boxesAP50Recall at 0.5
Helmet4140.77623.4%
Vest1380.71634.8%
Gloves930.43434.4%
No-gloves1570.36924.2%
No-vest1910.29859.2%
No-Helmet2440.21815.2%
All classes1,2370.46829.5%

The threshold is the biggest single cause of misses: 382 of the 872 missed boxes (44 percent) are found by the model at confidence 0.1 to 0.5. Helmets in particular often score 0.3 to 0.45. A lower or per-class threshold would recover many of them at some cost in false alarms.

Class mix-ups are rare; almost every error is a missed object or a detection with no label. Dropping the 40 test images whose filenames also appear in train moves mAP50 from 0.468 to 0.462.

Source: AAI3001 eval/README.md and eval/results/metrics.json, branch eval-2026-11

Per class, at a glance

The deployed checkpoint (best_deep.pt at 640 pixels) on the 255 held-out test images. Precision and recall here are Ultralytics' own, at the confidence that balances them best, so they differ from the 0.5 threshold in the table above. The eval scores the 8-bit, 320-pixel copy that runs on this page only as a whole (mAP50 0.41, against 0.47), not per class.

Precision share of its boxes that are right
  • Helmet0.78
  • Vest0.66
  • Gloves0.42
  • No-gloves0.61
  • No-vest0.23
  • No-Helmet0.24
Recall share of labelled items it finds
  • Helmet0.71
  • Vest0.62
  • Gloves0.53
  • No-gloves0.35
  • No-vest0.72
  • No-Helmet0.36
AP50 over all confidences, IoU 0.5
  • Helmet0.78
  • Vest0.72
  • Gloves0.43
  • No-gloves0.37
  • No-vest0.30
  • No-Helmet0.22

Hatched bars are the "No-" classes, the ones that raise an alert. Source: eval-summary.json, copied from eval/results/metrics.json in the test-set evaluation (run 11 Nov 2026).

Try it in your browser

The deployed detector, exported to ONNX at 320 pixels with 8-bit weights, runs on your device with onnxruntime-web. Run it on one of five held-out test images, or pick your own photo of people at work: it is read in this tab and never uploaded.

Nothing downloads until you press it. The runtime adds about 4 MB.

Or run it on a test image: one click loads the model and runs it.

This 8-bit, 320-pixel copy scores mAP50 0.41 on the held-out test split, against 0.47 for the full model at 640 pixels, so expect misses, especially on small or distant items. Weights: best_deep.pt from the team's Hugging Face repository, Ultralytics YOLOv8 (AGPL-3.0). Sample images: the project's held-out test split of the Personal Protective Equipment dataset on Roboflow Universe, CC BY 4.0, resized; chosen with no recognisable faces. What the model found in each is recorded in samples.json; scores in your browser can differ from it by a few points, because the browser resizes the image a little differently.

Where it misses

At the app's 0.5 threshold the deployed model finds 365 of 1,237 labelled items and misses 872. Each bar splits one class's labelled items into found, found with a score of 0.1 to 0.5 (lost to the threshold), and not found above 0.1. The packing line sample in the demo, marked as a known failure, comes from the factory CCTV images, the group with the lowest recall in the eval.

Labelled items found and missed per class at threshold 0.5, and false alarms
ClassLabelledFoundMissedFalse alarmsSplit
No-Helmet24437207 (85%)10337 found, 49 found but scored 0.1 to 0.5, 158 not found
Helmet41497317 (77%)397 found, 225 found but scored 0.1 to 0.5, 92 not found
No-gloves15738119 (76%)1138 found, 20 found but scored 0.1 to 0.5, 99 not found
Gloves933261 (66%)2032 found, 17 found but scored 0.1 to 0.5, 44 not found
Vest1384890 (65%)1048 found, 43 found but scored 0.1 to 0.5, 47 not found
No-vest19111378 (41%)263113 found, 28 found but scored 0.1 to 0.5, 50 not found

found at 0.5 scored 0.1 to 0.5 not found

Why the 872 misses happen

The first cause the eval script tags on each miss; each miss is counted once.

  • Found, but scored 0.1 to 0.5382
  • None of these causes217
  • Small object (under 0.5% of the image)132
  • Box in the wrong place (IoU 0.1 to 0.5)95
  • Called the wrong class23
  • Dark region (mean grey under 60)18
  • Overlapping labels3
  • Overexposed region (mean grey over 200)2

False alarms are not all wrong. Of the 410 at 0.5, 280 have no label nearby, and 228 of those are No-vest. The eval checked 12 of them by hand (2 No-Helmet, 10 No-vest): in all 12 the person really lacks the item and the label is missing, so the No- classes' precision is understated.

Counted from eval/results/failures_deployed_best_deep.json (one record per error, matched by class at IoU 0.5) through eval-summary.json.

The same 8-bit model file also runs as an HTTP service on a local Kubernetes cluster, as a C++ library and in a ROS 2 node in simulation, each measured: one detector, served three ways.

The PPE compliance dashboard: live camera detection with helmet and vest checks and the compliance log
Fig. 02.The PPE compliance dashboard: live camera detection with helmet and vest checks and the compliance log

How it works

  1. Frame in

    An uploaded image, a live camera frame or a video frame reaches the FastAPI backend over REST (POST /process-image or POST /process-video).

  2. Person detection

    YOLOv8n finds each person in the frame so every later check is per worker.

  3. Gear detection

    The custom YOLOv8s PPE model detects six classes: Gloves, Helmet and Vest, and their absence (No-gloves, No-Helmet, No-vest). The backend loads best_deep.pt by default and keeps detections at confidence 0.5 or higher; the README names best_100Epoch.pt as the production model.

  4. Pose estimation

    MediaPipe tracks 33 body landmarks on each person, drawn as the skeleton overlay in the UI.

  5. Dual validation

    The Dual Validation Engine combines Euclidean distance between gear box and person box with landmark matching, so a helmet only counts if it sits on the head landmarks.

  6. Compliance and history

    The Compliance Evaluator applies the sidebar requirement toggles to produce COMPLIANT or NON-COMPLIANT. The annotated frame, per-person breakdown and timestamp are saved to Supabase and shown in the Detection History dashboard.

What was hard

Getting a detector that is useful for safety rather than one that merely scores well. Iteration 1 trained on 100,000+ images and reached mAP50-95 of 0.53 but suffered severe class imbalance; the team moved to about 6,000 curated, re-annotated and balanced images (2,181 against 2,167 in iteration 4), and the production model reports mAP50-95 of 0.35 to 0.36 on validation during training. The trade-off the README commits to is high precision over recall. Measured on held-out images, that trade-off costs more than it looks: at the app's 0.5 threshold the deployed model finds 29.5 percent of labelled items, and 44 percent of its misses sit between 0.1 and 0.5 confidence.

Limits. The README's headline figures were validation scores from training; the held-out test mAP50 is 0.47. 40 test filenames also appear in train (without them mAP50 is 0.462), and the test labels look incomplete, mostly for No-vest: of 12 false alarms with no label nearby checked by hand (10 No-vest, 2 No-Helmet), the person really lacked the predicted item in all 12, so precision for the No- classes is pessimistic. The deployed checkpoint is the strongest of three on helmets but the weakest on every "No-" class, the classes that raise alerts. The pipeline runs at 1 to 2 FPS on CPU, so live mode is near real-time rather than video-rate.

Evidence

Held-out test, deployed model
255 images, 1,237 boxes, 640 pixels: mAP50 0.468, mAP50-95 0.217, precision 0.488, recall 0.547 (Ultralytics val). Run on 11 Nov 2026.AAI3001 eval/README.md and eval/results, branch eval-2026-11
Validation during training
Precision 0.75, recall 0.52 to 0.63, mAP50 0.62 to 0.64, mAP50-95 0.35 to 0.36. These match the validation scores stored in the checkpoints, not a held-out test.AAI3001 README, Performance Metrics; eval/README.md, section Headline
At the app's 0.5 threshold
Recall 29.5 percent, precision 47.1 percent (365 found, 872 missed, 410 false alarms). 382 of the misses (44 percent) are found at confidence 0.1 to 0.5.AAI3001 eval/README.md, section Error analysis
Inference speed
1 to 2 FPS on CPUAAI3001 README, Performance Metrics
Training evolution
Iteration 1: 100,000+ images, mAP50-95 0.53, class imbalance (86k hardhats). Iteration 5: about 6,000 curated, balanced images, mAP50-95 0.35 to 0.36 on validation, deployed. The README's stated lesson is that 6k curated beat 100k imbalanced in real-world use.AAI3001 README, Training Evolution
Dataset, counted from the label files
6,367 labelled images from 2,354 source images (train 5,847 after about 3x augmentation, valid 265, test 255), 23,410 boxes. The README's "about 6,000" counts the augmented copies.AAI3001 eval/README.md, section Dataset counts
Per class and failures
Per-class precision, recall and AP50 of the deployed model, and misses and false alarms per class at 0.5, copied from the eval files; 12 hand-checked false alarms with no label nearby: 10 No-vest, 2 No-Helmetpublic/demos/ppe-compliance/eval-summary.json, from AAI3001 eval/results (branch eval-2026-11)
Sample images in the demo
5 held-out test images, resized to 640 pixels, from the project's Roboflow dataset (CC BY 4.0); one, a packing line CCTV frame, is a known failure with 0 of 12 labelled items foundpublic/demos/ppe-compliance/samples.json, written by scripts/ppe-samples.py
Phase 1 helmet classifier
A separate ResNet-18 image classifier (helmet or no helmet), not the detector: 11 iterations, best 92.22 percent test accuracy (Run 10: SGD, Dropout 0.5, cleaned dataset)AAI3001 README, Phase 1
Weights and team
best_deep.pt (the backend default) and best_100Epoch.pt (22.5 MB) on Hugging Face; 88 commits, team of fivehuggingface.co/iMaximusiV/yolo-ppe-detector; repository metadata

Stack

  • Python 3.11
  • FastAPI 0.110
  • Ultralytics YOLOv8
  • MediaPipe Pose
  • OpenCV
  • Supabase
  • Vanilla JavaScript, HTML, CSS
  • Hugging Face Hub
  • ResNet-18 and Grad-CAM (Phase 1)