This project aims to detect helmets in images and videos using the YOLOv8 object detection algorithm. It provides a script that takes a folder path as input, detects helmets in all the images and videos within that folder, and saves annotated images and a CSV file with detection information in an output folder.
The objective of this project is to detect helmets in images and videos using the YOLOv8 object detection algorithm. The project workflow involves loading the pre-trained YOLOv8 model, resizing input frames, passing them through the model for object detection, visualizing the detections, and storing the results in annotated images and a CSV file.
python main.py <folder-path-containing-images>
- Python Programming Language
- OpenCV (Open Source Computer Vision Library) - to work with images and videos
- YOLOv8 (You Only Look Once) Model - to detect objects in images and videos
- Supervision (Python Package) - to visualize object detection and annotations
- Ultralytics (Python Package) - to use the YOLO model
- Load the pre-trained YOLOv8 model for helmet detection.
- Read input images or videos and resize the frames to the required size.
- Pass the resized frames through the YOLOv8 model to obtain the detected objects and their positions.
- Use the Supervision package to visualize the detections on the images.
- Store the resulting annotated images in a separate folder.
- Extract the labels of the detections from the YOLOv8 results.
- Evaluate the detections and generate a confusion matrix.
- Calculate accuracy and loss metrics and plot them using graphs.
- Store the generated graphs, along with the CSV file containing detection information, in the output folder.
The confusion matrix provides a comprehensive evaluation of the model's performance. Here is the confusion matrix for the helmet detection model:
- The model may not be accurate in all situations, and there may be false positives and false negatives. One way to improve the accuracy is to fine-tune the model on a larger and more diverse dataset.
- The current implementation only detects helmets, but it could be extended to detect other safety equipment such as safety glasses or gloves.
- The current implementation only works with images and videos, but it could be extended to work with live camera feeds.
In conclusion, your project involved detecting helmets in images and videos using a YOLO model. You used Python, OpenCV, YOLO, Supervision, and Ultralytics to implement the solution. The project workflow involved loading the YOLO model, reading the input images or video frames, passing them through the model, visualizing the detections, checking whether each person is wearing a helmet or not, and storing the results in a CSV file. There are potential improvements that could be made to the project, but overall it provides a good foundation for detecting safety equipment in images and videos.# helmet-detection