This project fine-tunes the YOLOv8n model on a custom dataset of crowded scenes with more cars and pedestrians. The goal was to improve the model's ability to detect and count vehicles and pedestrians in busy environments. After training for 100 epochs, the model showed some improvements over the pre-trained version in specific settings, though some misclassifications and overcounting still occur, requiring further training for more accuracy.
Below is a comparison video between the pre-trained YOLOv8n model and the fine-tuned model on a custom dataset of crowded scenes:
- Fine-Tuned YOLOv8n: Detects more cars and pedestrians in crowded scenes.
- Pre-Trained YOLOv8n: Misses several objects in similar scenes.
Fine-Tuned Model Output | Pre-trained Model Output |
---|---|
fine_tuned_yolov8n_video9.mp4 |
yolov8n_video9.mp4 |
fine_tuned_yolov8n_video3.mp4 |
yolov8n_video3.mp4 |
Fine-Tuned Model Output | Pre-trained Model Output |
---|---|
fine_tuned_yolov8n_video2.mp4 |
yolov8n_video2.mp4 |
fine_tuned_yolov8n_video7.mp4 |
yolov8n_video7.mp4 |
fine_tuned_yolov8n_video4.mp4 |
yolov8n_video4.mp4 |
The custom dataset was created by gathering images of crowded scenes and labeling the following object classes using the labelImg tool:
- person
- bicycle
- car
- truck
This step allowed for accurate fine-tuning of the YOLOv8n model to improve detection performance on these specific categories.
The pre-trained YOLOv8n model was fine-tuned on the custom dataset for 100 epochs. This process improved its accuracy in crowded scenes, particularly in detecting pedestrians. As shown in the chart, the overall loss has reduced over the epochs and led to improved accuracy. Code of this part can be seen at trainer.py
After fine-tuning the model, some tools provided by the Ultralytics YOLO library to count object in video sequences have been used. The code of this part can be seen at counter.py
.
- fine_tuned_yolov8n.pt: This is the best checkpoint of the fine-tuned model. Weights and other arguments can be found at
runs/detect/train
- yolov8n.pt: This is the base checkpoint used for fine-tuning on custom dataset, which is available at Ultralytics YOLO.