Automatic Pill Counting Using YOLOv8 to Improve Medication Distribution Accuracy

Main Article Content

Dinial Utami Nurul Qomariah
Ade Irma Elvira
Arvita Agus Kurniasari
Bima Wahyu Maulana

Abstract

Object detection is a critical component in various modern applications, including healthcare systems, smart agriculture, and industrial automation. The main challenge in developing detection systems lies in achieving high accuracy and strong generalization capabilities under diverse image conditions. This study aims to implement and evaluate the YOLOv8 model, a detection method known for its speed and efficiency. The model is trained using two scenarios—10 epochs and 50 epochs—to examine the impact of training duration on system performance. Evaluation results show that training for 10 epochs produces very good performance, with a precision of 0.98, recall of 0.94, and mAP of 0.98. Increasing the training to 50 epochs yields even more optimal results, achieving a precision of 0.99, recall of 1.00, and mAP of 0.99. Based on these findings, YOLOv8 demonstrates excellent adaptability to the dataset and is suitable for real-time detection applications that require high accuracy

Downloads

Download data is not yet available.

Article Details

How to Cite
Nurul Qomariah, D. U., Elvira, A. I., Agus Kurniasari, A., & Wahyu Maulana, B. (2026). Automatic Pill Counting Using YOLOv8 to Improve Medication Distribution Accuracy. International Journal of Public Health Excellence (IJPHE), 5(2), 28–33. https://doi.org/10.55299/ijphe.v5i2.1724
Section
Articles

References

R. A. Tariq, R. Vashisht, A. Sinha, and Y. Scherbak, Medication Dispensing Errors and Prevention. StatPearls Publishing, 2024. [Online]. Available: https://www.ncbi.nlm.nih.gov/books/NBK519065/

L. Tan, T. Huangfu, L. Wu, and W. Chen, “Comparison of RetinaNet, SSD, and YOLO v3 for real-time pill identification.,” BMC Med. Inform. Decis. Mak., vol. 21, no. 1, p. 324, Nov. 2021, doi: 10.1186/s12911-021-01691-8.

J. Heo, Y. Kang, S. Lee, D.-H. Jeong, and K.-M. Kim, “An Accurate Deep Learning-Based System for Automatic Pill Identification: Model Development and Validation.,” J. Med. Internet Res., vol. 25, p. e41043, Jan. 2023, doi: 10.2196/41043.

J. Redmon, S. Divvala, R. Girshick, and A. Farhadi, “You Only Look Once: Unified, Real-Time Object Detection.” 2016. [Online]. Available: https://arxiv.org/abs/1506.02640

T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollár, “Focal Loss for Dense Object Detection,” IEEE Trans. Pattern Anal. Mach. Intell., vol. 42, no. 2, pp. 318–327, 2020, doi: 10.1109/TPAMI.2018.2858826.

J. Holtkötter et al., “Development and Validation of a Digital Image Processing-Based Pill Detection Tool for an Oral Medication Self-Monitoring System,” Sensors, vol. 22, p. 2958, 2022, doi: 10.3390/s22082958.

W. Sun, X. Niu, Z. Wu, and Z. Guo, “Lightweight Detection Counting Method for Pill Boxes Based on Improved YOLOv8n,” Electronics, vol. 13, no. 24, 2024, doi: 10.3390/electronics13244953.

J. Moon, S. Lim, H. Lee, S. Yu, and K.-B. Lee, “Smart Count System Based on Object Detection Using Deep Learning,” Remote Sens., vol. 14, no. 15, 2022, doi: 10.3390/rs14153761.

M. Nikouei et al., “Small Object Detection: A Comprehensive Survey on Challenges, Techniques and Real-World Applications.” 2025. doi: 10.48550/arXiv.2503.20516.

W. Hua and Q. Chen, “A survey of small object detection based on deep learning in aerial images,” Artif. Intell. Rev., vol. 58, no. 6, p. 162, 2025, doi: 10.1007/s10462-025-11150-9.

H. Tjandrasa and C. Fatichah, “Segmentation of Microaneurysms for Early Detection of Diabetic Retinopathy Using MResUNet,” Int. J. Intell. Eng. Syst., vol. 14, pp. 359–373, 2021, doi: 10.22266/ijies2021.0630.30.

A. Kutlimuratov, J. Khamzaev, T. Kuchkorov, M. S. Anwar, and A. Choi, “Applying Enhanced Real-Time Monitoring and Counting Method for Effective Traffic Management in Tashkent,” Sensors, vol. 23, no. 11, 2023, doi: 10.3390/s23115007.

J. Peng et al., “Towards toxic and narcotic medication detection with rotated object detectors,” Quant. Imaging Med. Surg., vol. 13, 2023, doi: 10.21037/qims-21-1146.

Ultralytics, “YOLOv8,” Ultralytics YOLO Docs. [Online]. Available: https://docs.ultralytics.com/models/yolov8/

R. Sapkota and M. Karkee, “Ultralytics YOLO Evolution: An Overview of YOLO26, YOLO11, YOLOv8 and YOLOv5 Object Detectors for Computer Vision and Pattern Recognition.” 2025. doi: 10.48550/arXiv.2510.09653.

A. Bochkovskiy, C.-Y. Wang, and H. Liao, “YOLOv4: Optimal Speed and Accuracy of Object Detection.” 2020. doi: 10.48550/arXiv.2004.10934.

I. Fitri, “Catfish Fry Detection and Counting Using YOLO Algorithm,” J. Appl. Informatics Comput., vol. 7, no. 2, pp. 192–197, 2023.

Pillbox, “Pillbox - Archived Data,” Open Data Portal. [Online]. Available: https://datadiscovery.nlm.nih.gov/Chemicals-and-Drugs/Pillbox-Archived-Data/crzr-uvwg/data_preview

J. Torres, “YOLOv8 Architecture: A Deep Dive into its Architecture,” YOLOv8. [Online]. Available: https://yolov8.org/yolov8-architecture/

S. Ren, K. He, R. Girshick, and J. Sun, “Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks,” IEEE Trans. Pattern Anal. Mach. Intell., vol. 39, no. 6, pp. 1137–1149, 2017, doi: 10.1109/TPAMI.2016.2577031.

T.-Y. Lin, P. Dollár, R. B. Girshick, K. He, B. Hariharan, and S. J. Belongie, “Feature Pyramid Networks for Object Detection,” 2017 IEEE Conf. Comput. Vis. Pattern Recognit., pp. 936–944, 2016, [Online]. Available: https://api.semanticscholar.org/CorpusID:10716717

K. He, G. Gkioxari, P. Dollár, and R. Girshick, “Mask R-CNN,” in 2017 IEEE International Conference on Computer Vision (ICCV), 2017, pp. 2980–2988. doi: 10.1109/ICCV.2017.322.

K. Al-Hussaeni, I. Karamitsos, E. Adewumi, and R. M. Amawi, “CNN-Based Pill Image Recognition for Retrieval Systems,” Appl. Sci., vol. 13, no. 8, 2023, doi: 10.3390/app13085050.