Built to order

AI-Based Helmet Recognition for Two-Wheeler Riders using YOLOv12

This project builds an AI system that recognises whether each two-wheeler rider is wearing a helmet, using a YOLOv12 object-detection model trained on the Roboflow Universe helmet dataset. Every rider is located, the head region is checked for a helmet, and each rider gets a pass-or-flag verdict with a confidence score, logged with a timestamp for campus-gate or parking-entry review. It ships with the training notebook, the trained model, and a working web dashboard demo. Suitable for B.E./B.Tech final-year projects in Computer Science, IT and AI & Machine Learning.

Chat on WhatsApp — get a quotation

AI & Machine Learning PythonOpenCVGitNumPy · MatplotlibRoboflow helmet datasetONNX RuntimeHTML dashboard demoPyTorch Ultralytics YOLOv12Software
AI-Based Helmet Recognition for Two-Wheeler Riders using YOLOv12 — project thumbnail preview
More project photos (2)

The problem

Helmet recognition for two-wheeler riders is a rider-level detection task: a camera frame is scanned for two-wheelers, each rider's head region is located, and the rider is classified as wearing a helmet or not. This project builds that system with YOLOv12, Ultralytics' attention-based detector released in February 2025, fine-tuned on the Roboflow Universe "Helmet Wearing Detection" dataset of about 12,000 traffic images. Unlike a whole-frame classifier, it judges every rider separately, so one helmeted rider next to one bare-headed rider produces two different verdicts instead of one confused answer. The area-attention mechanism in YOLOv12 keeps a large receptive field at low cost, which matters because a distant rider's head is only a few dozen pixels wide. A web dashboard shows live bounding boxes, per-rider verdicts with confidence scores, and a timestamped compliance log for campus-gate or parking-entry review, with the trained model, training notebook and report shipped for the viva.

SYSTEM FLOW

6 components 5 connections

Live flow
Drag to explore
100%
sensorCamera feed

USB or IP camera at the gate captures each passing two-wheeler.

How it works

End to end, the system turns a camera frame into one verdict per rider. The frame is resized to 640 × 640 and passed to the fine-tuned YOLOv12n network, which predicts bounding boxes for three classes — Two Wheeler, Helmet and Without Helmet — in a single forward pass. Non-maximum suppression with an IoU of 0.5 removes duplicate boxes, then each head-region box is matched to the two-wheeler box that contains it, so a helmet is always attributed to the correct rider even when several riders share a frame. A rider whose head box is a Helmet passes; a rider whose head box is Without Helmet, or whose head region has no helmet box at all, is flagged. Verdicts above the confidence threshold are drawn on the dashboard and written to the compliance log with a timestamp and a cropped snapshot; verdicts below the threshold are shown as uncertain and never logged as flags.

  1. A camera frame (or uploaded photo) is resized to 640 × 640 and normalized for the YOLOv12n network.
  2. The network predicts bounding boxes for three classes — Two Wheeler, Helmet and Without Helmet — in one forward pass.
  3. Non-maximum suppression (IoU 0.5) removes duplicate boxes, keeping the highest-confidence box per object.
  4. Each Helmet or Without Helmet box is matched to the Two Wheeler box that contains it, attributing every head to its rider.
  5. A rider with a Helmet box passes; a rider with a Without Helmet box, or no helmet box in the head region, is flagged.
  6. Verdicts above the confidence threshold (0.35 default) are drawn on the dashboard and logged with a timestamp and cropped snapshot.

Tech stack:

  • Python 3, PyTorch, Ultralytics YOLOv12

  • OpenCV (frame capture & drawing)

  • Roboflow helmet dataset

  • ONNX Runtime (inference)

  • HTML/CSS/JavaScript dashboard

  • NumPy, Matplotlib (metrics & plots)

  • Jupyter Notebook (training & evaluation)

  • Git

  • Dataset: Roboflow Universe "Helmet Wearing Detection" — approximately 12,000 annotated traffic images (10,494 train / 992 validation / 512 test), three classes (Helmet, Without Helmet, Two Wheeler), YOLO-format bounding boxes, varied daylight lighting and camera angles.

  • Task: Multi-class object detection; input = 640×640×3 frame, output = bounding boxes with class label and confidence, then one helmet verdict per rider.

  • Model: YOLOv12n (2.6 M parameters, 7.5 GFLOPs at 640 px, Ultralytics docs), fine-tuned from COCO-pretrained weights; area attention (feature maps split into 4 regions) plus R-ELAN blocks with residual connections; NMS IoU 0.5; confidence threshold 0.35 default (operator-adjustable).

  • Metrics: mAP@0.5, mAP@0.5:0.95, per-class precision/recall and confusion between Helmet and Without Helmet. Development targets for the built-to-order training run: mAP@0.5 approximately 0.85, helmet-class precision approximately 0.90 — targets, not measured results. No accuracy is claimed as measured until the training run is executed for the order.

YOLOv12 vs YOLOv8 for this task

Model Parameters FLOPs (640 px) mAP50-95 (COCO) Attention Small-head detection
YOLOv12n 2.6 M 7.5 G 40.6 Area attention + R-ELAN Large receptive field at low cost
YOLOv8n 3.2 M 8.7 G 37.3 None (CNN only) Weaker at distance
Figures from the Ultralytics model docs (COCO val2017). A distant rider's head is a few dozen pixels wide, so the large receptive field that area attention provides at low cost is the reason YOLOv12 was chosen over YOLOv8 for this task.
Parameter Value
Input resolution 640 × 640 pixels
Classes 3 — Helmet · Without Helmet · Two Wheeler
Model YOLOv12n — 2.6 M parameters (Ultralytics docs)
Compute 7.5 GFLOPs at 640 px (Ultralytics docs)
COCO mAP50-95 40.6 for pretrained YOLOv12n (Ultralytics docs · COCO val2017)
Helmet-task mAP@0.5 Approximately 0.85 (development target — not a measured result)
NMS IoU 0.5
Confidence threshold 0.35 default (operator-adjustable 0.25–0.90)
Inference reference 1.64 ms on NVIDIA T4 with TensorRT FP16 (Ultralytics docs · COCO benchmark)
Export ONNX (expected)
Demo sample set 4 photos · 8 riders — 4 with helmet · 4 without (counted in this build)
Training 100 epochs (training configuration)

Project features

The build's core capabilities are rider-level verdicts, a review log, and a working dashboard. First, every rider in a frame is detected and judged separately, so mixed groups — one helmeted rider beside one without — are handled correctly instead of collapsing into a single frame-level label. Second, each verdict carries a confidence score and a timestamp, and flagged riders are saved as cropped snapshots in a review log that a gate operator can check later. Third, the web dashboard presents the camera feed with bounding boxes, a live compliance count, and per-hour compliance charts, so the system's behaviour is visible during a demonstration. Fourth, the model exports to ONNX, so the same trained weights run in a plain Python service without the training stack. Around these four, the build adds an adjustable confidence threshold and a small-head augmentation recipe for distant riders.

  • [Rider-level helmet verdict] Each rider in a frame gets an individual pass-or-flag verdict, so a helmeted rider and a bare-headed rider in the same image are never confused with each other.
  • [Three-class YOLOv12 detection] One YOLOv12n network predicts Two Wheeler, Helmet and Without Helmet boxes in a single pass, with head boxes matched to their rider by spatial overlap.
  • [Timestamped compliance log] Every verdict above the confidence threshold is logged with a timestamp, rider ID and cropped snapshot, giving a reviewable record for a campus gate or parking entry.
  • [Live web dashboard] The dashboard shows the camera feed with bounding boxes, the current compliance count, the latest detections, and per-hour compliance charts for demonstrations.
  • [Adjustable confidence threshold] The operator can move the flag threshold between 0.25 and 0.90 from the dashboard, trading false flags against missed riders without retraining.
  • [ONNX export] The trained weights export to ONNX, so inference runs in a plain Python service with ONNX Runtime and no training stack is needed at demo time.
  • [Small-head augmentation (optional add-on)] Extra training-time augmentation for distant, small heads can be added on request; the base build trains on the standard dataset split.

What is included

  • Complete training & evaluation Jupyter notebook
  • Trained YOLOv12n model file (.pt) with preprocessing code
  • ONNX export of the trained model
  • Live web dashboard demo with bounding boxes, verdicts and compliance log
  • Compliance-log schema and sample review snapshots from the demo set
  • Project report PDF (background, YOLOv12 theory, dataset, methodology, results)
  • PPT presentation for final review
  • Viva Q&A preparation document (attention, R-ELAN, NMS, mAP, rider association)

Limitations & prerequisites

  • YOLOv12 is listed by Ultralytics as a community research model, with YOLO11/YOLO26 recommended for production use — the report discusses this trade-off openly.
  • Small or distant heads, heavy occlusion and night or low-light frames reduce reliability; the dataset is mostly daylight traffic images.
  • No number-plate recognition in the base build — it is an optional add-on, not included by default.
  • A flagged snapshot is a review aid for a gate operator, not legal evidence; this is not an enforcement or challan system.
  • Faces appear in review snapshots, so a face-blur step is needed before any public deployment.
  • All helmet-task accuracy figures are development targets; the actual mAP depends on the training run and is documented after training.

Frequently Asked Questions

Which dataset is used and what are its classes?

The Roboflow Universe "Helmet Wearing Detection" set — about 12,000 annotated traffic images with YOLO-format boxes — has three classes: Helmet, Without Helmet and Two Wheeler, split into 10,494 training, 992 validation and 512 test images. The classes were checked against the dataset's own listing before the page was written, so the labels match what the dataset actually contains.

Why YOLOv12 instead of YOLOv8?

YOLOv12n is smaller and stronger on the published COCO figures — 2.6 M parameters and 40.6 mAP50-95 against YOLOv8n's 3.2 M and 37.3. Its area attention keeps a large receptive field at low cost, which helps with distant riders' small heads.

How does it handle several riders in one frame?

Each head box is matched to the two-wheeler box that contains it, so every rider is judged on their own head region. A helmeted rider next to a bare-headed rider gets two separate verdicts, not one frame-level label, and passengers are judged the same way when their head region is visible, while a rider whose head is fully hidden behind another rider is reported as uncertain rather than guessed.

Can it work with a live camera?

Yes — the delivered code reads frames from a USB camera or an IP camera stream with OpenCV and runs the same detection loop shown in the dashboard demo. A still photo can be uploaded instead when no camera is available.

Is the accuracy guaranteed?

No. No accuracy is claimed as measured: the helmet-task figures are development targets (mAP@0.5 approximately 0.85) for the training run built for the order, and the report documents the actual achieved mAP, precision and recall after training, so the numbers shown are real.

Is this project suitable for a final-year project?

Yes — for Computer Science, IT and AI & Machine Learning programs, because it demonstrates object detection, attention-based architectures, dataset handling, evaluation with mAP, and a working deployment dashboard in one build, and the report and presentation cover each of those topics for the viva.

Components & software requirements
  • Python 3, PyTorch, Ultralytics YOLOv12
  • OpenCV (frame capture & drawing)
  • Roboflow helmet dataset
  • ONNX Runtime (inference)
  • HTML/CSS/JavaScript dashboard
  • NumPy, Matplotlib (metrics & plots)
  • Jupyter Notebook (training & evaluation)
  • Git
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download free synopsis (PDF)

Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.

Get a quotation