Triple-Rider Detection is a computer vision project that detects motorcycles with more than two riders and checks for helmet compliance. Additionally, it identifies if the motorcycle is being used on a mobile device. This project utilizes YOLOv8, trained on a custom dataset of over 6,000 images, to achieve high-performance detection.
- Project Description
- Installation Instructions
- Usage Instructions
- Dataset Information
- Training Details
- Preprocessing
- Sample Output Images
Triple-Rider Detection aims to enhance motorcycle safety by identifying whether a motorcycle has more than two riders and ensuring all riders are wearing helmets. The project also detects if the motorcycle is being used on a mobile device. The system uses YOLOv8 for object detection, providing real-time feedback on helmet compliance and usage status.
-
Clone the Repository:
git clone https://github.com/yourusername/triple-rider-detection.git cd triple-rider-detection
-
Set Up the Environment:
Create a virtual environment and install dependencies:
python -m venv env source env/bin/activate # On Windows use: env\Scripts\activate pip install -r requirements.txt
-
Install Roboflow Inference SDK:
pip install inference-sdk
-
Obtain a Roboflow API Key:
To use the Roboflow API, you need your own API key. Follow these steps:
- Sign up for a Roboflow account at Roboflow.
- Create a new project and upload your dataset.
- Retrieve your API key from the Roboflow dashboard.
-
Update API Key and Model ID:
Replace the
YOUR_API_KEY
,YOUR_IMAGE.jpg
, andmodel_id
with your actual values in the code snippet below.# import the inference-sdk from inference_sdk import InferenceHTTPClient # initialize the client CLIENT = InferenceHTTPClient( api_url="https://detect.roboflow.com", api_key="YOUR_API_KEY" # Replace YOUR_API_KEY with your actual API key ) # infer on a local image result = CLIENT.infer("path/to/your/image.jpg", model_id="3riders/2")
-
Run Inference:
Save the above code to a Python file and execute it to perform inference on your image.
The dataset used for training includes a custom collection of images created specifically for this project. It is divided as follows:
- Train Set: 87% (5,295 images)
- Validation Set: 8% (514 images)
- Test Set: 4% (248 images)
This custom dataset was designed to provide a diverse range of scenarios to improve the accuracy and robustness of the model in detecting motorcycles with more than two riders, helmet compliance, and mobile usage.
- Model: YOLOv8
- Training Set Size: 6,000 images
- Performance Metrics:
- mAP: 81.7%
- Precision: 80.8%
- Recall: 75.0%
- Auto-Orient: Applied
- Resize: Stretch to 640x640
- Augmentations:
- Flip: Horizontal, Vertical
- Rotation: 90° Clockwise, Counter-Clockwise
- Crop: 0% Minimum Zoom, 22% Maximum Zoom
- Rotation: Between -11° and +11°
- Shear: ±12° Horizontal, ±12° Vertical
Description: Example of motorcycle with more than two riders detected.
Description: Example of helmet compliance detection.
Description: Example of detection results with bounding boxes and labels.
Description: Example of motorcycle detection with mobile usage.