Motorcycle Helmet Violation & Overloading Detection System
A real-time computer vision system that detects motorcycle safety violations including helmet non-compliance and overloading (≥3 riders). Built for CS 176 (Computer Vision) Final Project.
- Installation
- Usage Guide
- Model Details
- Results
- Limitations
- Future Improvements
- Project Structure
- Authors
- Python 3.10+
git clone https://github.com/yourusername/thinkahead.git
cd thinkaheadconda create -n thinkahead python=3.10
conda activate thinkaheadpip install -r requirements.txtstreamlit run src/app_streamlit.pyThen open http://localhost:8501 in your browser.
Features:
- Upload images or videos
- Adjust detection confidence threshold
- View real-time statistics
- Download violation logs as CSV
- Base Model: YOLOv8m (Medium)
- Parameters: 25.9M
- Input Size: 640×640
- Framework: Ultralytics + PyTorch
| Class ID | Class Name | Description |
|---|---|---|
| 0 | motorcycle |
Two-wheeled motor vehicle |
| 1 | rider |
Person on motorcycle |
| 2 | helmet |
Person wearing helmet |
| 3 | no_helmet |
Person without helmet |
| 4 | license_plate |
Vehicle registration plate |
| Parameter | Value |
|---|---|
| Epochs | 100 |
| Batch Size | 8 |
| Image Size | 640×640 |
| Optimizer | AdamW |
| Learning Rate | 0.001 → 0.00001 |
| Augmentation | Mosaic, HSV, Flip, Scale |
| Split | Images |
|---|---|
| Train | 1,798 |
| Validation | 224 |
| Test | 226 |
| Total | 2,248 |
Sources:
- Roboflow Helmet-and-Number-Plate dataset
- Roboflow Triple Riding Detection dataset
- Kaggle Helmet Detection dataset
YOLO Detection → Geometric Grouping → Violation Logic → OCR (optional)
- Geometric Grouping: Associates riders with motorcycles based on bounding box overlap and proximity
- Helmet Detection: Checks if helmet bbox overlaps upper portion of rider bbox
- Overload Detection: Flags motorcycles with ≥3 associated riders
- OCR Module: Extracts license plate text for violations (using EasyOCR)
| Metric | Value |
|---|---|
| mAP@50 | 76.1% |
| mAP@50-95 | 39.3% |
| Precision | 74.9% |
| Recall | 77.2% |
| Class | AP@50 | Notes |
|---|---|---|
| license_plate | 99.5% | Excellent detection |
| helmet | 84.5% | Strong performance |
| motorcycle | 80.2% | Reliable detection |
| no_helmet | 59.6% | Moderate - challenging class |
| rider | 27.1% | Low - often subsumed by helmet/no_helmet |
- Motorcycle: 85% correct classification
- Helmet: 87% correct classification
- No_helmet: 63% correct (some confusion with background)
- Rider: 29% correct (often classified as background)
- False positives in dense traffic - Crowded scenes may cause incorrect rider-motorcycle associations
- Extreme viewing angles - Side/rear views may miss helmet detection
- Nighttime performance - Depends heavily on lighting conditions
- Rider occlusion - Overloading detection fails when riders occlude each other
- Small objects - Distant motorcycles may not be detected reliably
- Class imbalance - "Rider" class underrepresented relative to helmet/no_helmet
- Geographic bias - Primarily South Asian traffic scenarios
- License plate formats - Optimized for certain plate styles
- VRAM requirements - Minimum 4GB for inference
- Real-time constraints - May require frame skipping on lower-end hardware
- OCR accuracy - License plate reading affected by motion blur and resolution
- Add temporal tracking (DeepSORT) for consistent ID assignment across frames
- Implement confidence calibration for violation alerts
- Add support for more license plate formats
- Nighttime enhancement using IR cameras or low-light models
- Multi-camera support for wider coverage
- Database integration for violation logging
- Expand to other violations (wrong-way driving, lane filtering)
- Edge deployment (Jetson Nano, Raspberry Pi)
- Integration with traffic management systems
- Roboflow Universe - Helmet and Number Plate Detection
- Roboflow Universe - Triple Riding Detection
- Kaggle - Helmet Detection Dataset
Noval & Sacramento
CS 176 - Computer Vision
University of the Philippines Diliman
2nd Semester, AY 2024-2025
This project is for educational purposes as part of CS 176 coursework.