A computer vision project that detects the helmet usage dof the mototrcycle riders during the traffic, using YOLOv8 and PyTorch
--
This project implements a helmet detection system that can identify whether motorcycle riders wear their helmets or not in images and videos. The system uses deep learning object detection trained with a custom dataset and perform a realtime inference, using OpenCV.
The goal of this project is to explore the real life applications of machine learning and computer vision in the traffic safety and monitoring.
--
- The helmet and no helmet detection system
- The YOLOv8-based object detection model
- The custom dataset
- Video Stream Processing with OpenCV
--
HelmetProject/
├── dataset/
│ └── data.yaml
├── train.py
├── Test.py
├── CapturePic.py
├── runs/
├── weights/
├── .gitignore
└── README.md
This model is trained using Ultralytics YOLOv8
from ultralytics import YOLO
model = YOLO(yolov8n.pt)
model.train(
data="dataset/data.yaml",
imgsz=640,
epochs=80,
batch=8,
freeze=5
)The t🚀ain results, including the evaluation metrics and weights, will be save under
runs/detect/train*/weights
Due to the GitHub file size limitations, the train model weights (e.g. best.pt) are not included included in this respiratory.
To obtain the trained weights;
- run train.py locally
- best.pt will be generated under
runs/detect/train*/weights
To use your trained model for inference:
from ultralytics import YOLO
model = YOLO("path/to/best.pt")A demo video can be recorded using:
- macOs screen recording system
- OBS Studio
- Python
- Ultralytics YOLOv8
- OpenCV
- PyTorch
- GitHub
- improve dataset diversity for better generalization
- Deploy a web application or API
This project was developped for the educational purpose to gain some hand on experience on the real world application of machine learning.