Vehicle Classification with YOLOv8

Robust detection of 6 vehicle classes for smart traffic monitoring

By Fahri Zanuar Pradian•GitHub Repository

Abstract

In the context of intelligent transportation systems, accurate vehicle detection and classification are paramount for traffic flow analysis and automated toll collection. This project presents a deep learning-based object detection pipeline leveraging the YOLOv8 architecture to classify six distinct categories of vehicles commonly found in South Asian and Southeast Asian traffic: Car, Threewheel, Bus, Truck, Motorbike, and Van.

By utilizing a balanced dataset and employing transfer learning on the YOLOv8 Small (yolov8s.pt) model, the system achieves an excellent trade-off between inference speed and mean Average Precision (mAP@50), demonstrating strong generalization across diverse traffic conditions.

Methodology

1. Dataset Description

The model was trained on a comprehensive vehicle dataset sourced from Kaggle (nadinpethiyagoda/vehicle-dataset-for-yolo). The dataset was carefully curated to ensure balanced representation across the 6 target classes. This diversity, particularly the inclusion of "Threewheel" (tuk-tuks) alongside standard vehicles, makes the model highly applicable to real-world traffic scenarios in developing regions.

2. Model Choice: YOLOv8 Small

The YOLOv8 Small (YOLOv8s) model was selected as the core architecture. Ultralytics' YOLOv8 represents the state-of-the-art in real-time object detection, offering significant improvements in accuracy and speed over its predecessors. The Small variant was specifically chosen because it provides an optimal balance: it is lightweight enough to run in real-time on edge devices (such as traffic cameras or Jetson Nanos) while maintaining a high mAP, which is crucial for distinguishing between visually similar classes like Cars and Vans in crowded scenes.

3. Training Configuration

Quantitative Evaluation

The model achieved an exceptional overall mAP@50 of 98.3%. Notably, it also recorded an average inference speed of 6.7ms per image on a Tesla T4 GPU, demonstrating its high efficiency.

ClassmAP@50
All Classes0.983
Car0.964
Threewheel0.994
Bus0.992
Truck0.984
Motorbike0.971
Van0.993

Inference Results

The following images demonstrate the model's performance on unseen data from the validation set. Bounding boxes indicate the detected vehicle class along with the confidence score. The model successfully detects multiple overlapping vehicles, handles varying scales, and accurately identifies the Threewheel class.

Inference Result 1
Fig 1: Inference output for `canva-tuk-tuk-MADB6DCAh2s.jpg`
Inference Result 2
Fig 2: Inference output for `car134.jpg`
Inference Result 3
Fig 3: Inference output for `car136.jpg`
Inference Result 4
Fig 4: Inference output for `car172.jpg`
Inference Result 5
Fig 5: Inference output for `car91.jpg`
Inference Result 6
Fig 6: Inference output for `indianvan30.jpg`
Inference Result 7
Fig 7: Inference output for `istockphoto-468967228-170667a.jpg`
Inference Result 8
Fig 8: Inference output for `phnom-penh-cambodia-april-11-260nw-1408096805.jpg`
Inference Result 9
Fig 9: Inference output for `srilankavan13.jpg`
Inference Result 10
Fig 10: Inference output for `srilankavan43.jpg`

Interactive Demo

You can test the trained model (yolov8s_smart_traffic_best.pt) live using the interactive space below. Upload your own image of traffic or vehicles to see the YOLOv8 model perform classification and bounding box detection in real-time.

Challenges & Limitations

Conclusion

The YOLOv8 pipeline demonstrates robust vehicle classification capabilities across 6 distinct classes. Its ability to maintain high precision even with classes like the Threewheel makes it a highly viable solution for intelligent traffic monitoring systems in diverse environments. Furthermore, this YOLOv8 Small model achieves not only exceptional accuracy but also meets rigorous low-latency inference standards (~6.7ms). This makes it highly deployable for real-time live-streaming endpoints, as demonstrated by the Interactive Demo above.