Helmet Detection with YOLOv5

July 23, 2023

This tool detects helmets in a live feed with YOLOv5 and some custom logic. It utilises pre-trained YOLOv5 models and a custom-trained helmet detection model.

I trained a model to detect whether a person is wearing a helmet or not from a dataset from Kaggle. I increased the bounds' sizes by 20% for the pictures containing helmets to include the person's shoulders too, allowing my model to detect whether the helmet was on the person's head or not. Apart from my model, I also used the pre-trained YOLOv5 model to detect people and motorcycles in the frame.

I combined the outputs of both models by finding Intersection over Union (IoU) between the bounding boxes of the helmet, person, and motorcycle.

Helmet InputHelmet Custom Output
Helmet YOLO OutputHelmet Total Output

This project has potential applications in traffic safety enforcement and compliance monitoring. It can be combined with an OCR system to extract the number plate information from the vehicle and automatically send fines to traffic rule offenders.


Technologies used:

  • Python
  • PyTorch (YOLOv5)
  • OpenCV
  • Numpy
  • Matplotlib