This project presents a deep learning-based system for detecting traffic objects using YOLOv8. The model is trained to identify important road elements such as vehicles and traffic signs, aiming to simulate a simplified smart traffic monitoring system.
The system can detect multiple objects in an image and output bounding boxes, class labels, and confidence scores.
- Build an object detection model using YOLOv8
- Detect key traffic elements from images
- Evaluate model performance on validation and external images
- Understand challenges such as class imbalance and generalization
The dataset used in this project is the Traffic Violation Detection Dataset, sourced from Kaggle.
It contains annotated images in YOLO format covering multiple traffic-related classes such as vehicles, traffic lights, and road signs.
Due to size constraints, the dataset is not included in this repository.
To improve model performance, the dataset was cleaned and filtered by:
- Removing underrepresented classes
- Reducing class imbalance
- Keeping only the most relevant classes
- Removing images with no valid annotations after filtering
This resulted in a smaller but more balanced dataset.

The model was trained on the following 10 classes:
- Car
- Truck
- Bus
- Red Light
- Green Light
- Stop Sign
- No Left Turn
- No Right Turn
- No Stopping
- No U-turn
- Model: YOLOv8n (lightweight and fast)
- Framework: Ultralytics YOLO
- Training environment: Google Colab
- Input size: 640x640
- Epochs: 10–20
The model achieved strong performance on the validation dataset:
- mAP50 ≈ 0.887
- mAP50-95 ≈ 0.741
- Precision ≈ 0.843
- Recall ≈ 0.834
- Stop Sign: Very high accuracy (mAP50 ≈ 0.995)
- Traffic Lights: Good detection with moderate confidence variation
- Vehicles (Car, Truck, Bus): Stable and consistent performance
- Turn Restrictions: High accuracy in most cases
- The model performs very well on clear and well-represented classes
- Strong detection consistency across multiple classes
- Some variation in performance for smaller or less frequent objects
- Strong performance on clear objects (e.g., stop signs, vehicles)
- Good detection in both day and night conditions
- Moderate performance on traffic lights (lower confidence in some cases)
- Occasional missed detections in complex scenes
- Limited dataset size affects generalization
- Some confusion between similar classes (e.g., traffic lights)
- Lower confidence in challenging conditions (lighting, angles)
- Dataset contains cropped objects, which may reduce real-world performance
- Python
- PyTorch
- Ultralytics YOLOv8
- Google Colab
This project demonstrates a practical implementation of object detection in traffic scenarios using YOLOv8. The model performs well within the constraints of limited data and time, and highlights common challenges such as dataset quality and generalization.