YOLOv8
View our interactive Python notebook at Kaggle here.
For this method, we performed transfer learning on the YOLOv8 model (specifically YOLOv8n) pretrained on the COCO dataset from Ultralytics, freezing the backbone. Our goal is to see how YOLOv8 would perform in contrast to YOLOv4 used in a previous work by Mulyanto et al. (2020).
Data preprocessing
Similar to the traditional methods, we used the Indonesia Traffic Sign dataset from Kaggle. However, as YOLO does not need a “null class” in the dataset directly, we do not combine it with another dataset.
We split the dataset with a ratio of train : validation : test = 70 : 20 : 10 with stratification, resulting in a total of 1470, 420, and 210 data points for the train, validation, and test split respectively. This time, along with the images, we also used the bounding box data that was provided by the dataset.
As image resizing is already part of the YOLOv8 pipeline, we did not perform any explicit resizing. Also, YOLOv8 can handle RGB images as input, so we did not do any preprocessing that we performed during the traditional methods.
Finally, we perform data augmentation. For each data point in the training set, we create two copies:
- One copy after rotating the image and the bounding boxes by a small angle.
- One copy after randomly adjusting the brightness and contrast.
A comparison of the original image and and the images after augmentation is as follows. The bounding boxes are also drawn on the images.

In this step, we also perform some file management and format the filenames and directories to be able to be used with YOLOv8.
We also created the YAML file for configuring our custom dataset for the model as follows.
1names:
2- larangan-berhenti
3- larangan-masuk-bagi-kendaraan-bermotor-dan-tidak-bermotor
4- larangan-parkir
5- lampu-hijau
6- lampu-kuning
7- lampu-merah
8- larangan-belok-kanan
9- larangan-belok-kiri
10- larangan-berjalan-terus-wajib-berhenti-sesaat
11- larangan-memutar-balik
12- peringatan-alat-pemberi-isyarat-lalu-lintas
13- peringatan-banyak-pejalan-kaki-menggunakan-zebra-cross
14- peringatan-pintu-perlintasan-kereta-api
15- peringatan-simpang-tiga-sisi-kiri
16- peringatan-penegasan-rambu-tambahan
17- perintah-masuk-jalur-kiri
18- perintah-pilihan-memasuki-salah-satu-jalur
19- petunjuk-area-parkir
20- petunjuk-lokasi-pemberhentian-bus
21- petunjuk-lokasi-putar-balik
22- petunjuk-penyeberangan-pejalan-kaki
23nc: 21
24test: /kaggle/working/data_yolo/images/test
25train: /kaggle/working/data_yolo/images/train
26val: /kaggle/working/data_yolo/images/valModel training and evaluation
We trained the YOLOv8 model with a frozen backbone. We did 50 epochs with an image size of 640 × 640. The weights are saved to a .pt file and is available to download here.
We then ran inference on the validation dataset (for final verification) as well as evaluating our model’s performance on the test dataset. The results are as follows.
| Box Precision | Box Recall | mAP50 | mAP50-95 | |
|---|---|---|---|---|
| Train | 0.970 | 0.912 | 0.968 | 0.822 |
| Validation | 0.963 | 0.924 | 0.968 | 0.827 |
| Test | 0.952 | 0.943 | 0.974 | 0.842 |
Below, we present sample predictions made by the model. The bounding boxes fit the image well and the model seems to have excellent performance.

The confusion matrix is as follows.

Comparing our results with the previous work of Mulyanto et al. (2020), we achieved a mAP50 value of 97.4% on 21 classes, which shows a better performance from the previous result of 74.91% on 26 classes. While we have a smaller number of classes, the results still show significant improvement, showing the better performance of the newer model of YOLOv8.
References
Mulyanto, A., Borman, R. I., Prasetyawan, P., Jatmiko, W., Mursanto, P., & Sinaga, A. (2020). Indonesian Traffic Sign Recognition for Advanced Driver Assistent (ADAS) Using YOLOv4. In F. W. Wibowo (Ed.), 2020 3rd International Seminar on Research of Information Technology and Intelligent Systems, ISRITI 2020 (pp. 520-524). Article 9315368 (2020 3rd International Seminar on Research of Information Technology and Intelligent Systems, ISRITI 2020). Institute of Electrical and Electronics Engineers Inc. https://doi.org/10.1109/ISRITI51436.2020.9315368