Binary classification of defects in multiple coffee beans using lightweight convolutional neural networks for embedded systems

Authors

DOI:

https://doi.org/10.56294/dm2025840

Keywords:

Coffee beans classification, coffee defects, CNN, YOLO, lightweight network

Abstract

Coffee and its derivatives are part of the world's gastronomy and are also one of the main export products in Imbabura, Ecuador. Coffee producers and marketers must ensure the quality of their coffee beans, as a single seed can present several morphological defects. However, the selection of quality beans is a manual, tedious, and time-consuming process, prone to misclassification due to human limitations such as fatigue and varying subjective classification criteria. This work aims to detect and classify multiple coffee beans automatically present in an image (both good and bad) using modern convolutional neural networks, specifically YOLOv11 (Nano and Small variants), which are selected for their computational efficiency and good performance in real-time detection tasks. A custom dataset with a total of 4,090 RGB images with multiple coffee beans randomly located within each image was collected and manually labeled into two classes (good and bad) using the CVAT tool. Image preprocessing included background variation (white, gray, and black) to improve dataset variability and model robustness. Models were trained on the Kaggle platform with an NVIDIA Tesla P100 GPU (16 GB VRAM), using the PyTorch framework and the Ultralytics library. Results showed an accuracy of 0.880 for YOLO v11-Nano and 0.871 for YOLO v11-Small, along with inference times of 7.89 ms (126.7 fps) and 10.08 ms (99.20 fps), respectively. These results are comparable to those reported in the literature, but now considering the challenge of superimposing multiple coffee beans randomly located in each image with a variable background. These results suggest the potential for applying the model to embedded systems in practical settings for small and medium-sized producers and associations, thereby contributing to technological innovation in the Ecuadorian coffee sector.

References

1. Durán-Aranguren DD, Robledo S, Gomez-Restrepo E, Arboleda Valencia JW, Tarazona NA, Robledo DD;, et al. Scientometric Overview of Coffee By-Products and Their Applications. Molecules 2021, Vol 26, Page 7605 [Internet]. 2021 Dec 15 [cited 2025 Jul 2];26(24):7605. https://doi.org/10.3390/MOLECULES26247605. DOI: https://doi.org/10.3390/molecules26247605

2. León-Serrano LA, Matailo-Pinta AM, Romero-Ramón AA, Portalanza-Chavarría CA. Ecuador: producción de banano, café y cacao por zonas y su impacto económico 2013-2016. Revista Científica UISRAEL [Internet]. 2020 Sep 10 [cited 2024 Apr 21];7(3):103–21. https://doi.org/10.35290/RCUI.V7N3.2020.324. DOI: https://doi.org/10.35290/rcui.v7n3.2020.324

3. USDA. Ecuador: Coffee Annual | USDA Foreign Agricultural Service [Internet]. 2023 [cited 2025 Jun 22]. Available from: https://www.fas.usda.gov/data/ecuador-coffee-annual-6

4. MAGAP. MAGAP ejecuta “Proyecto de Reactivación de la Caficultura Ecuatoriana” – Ministerio de Agricultura y Ganadería [Internet]. 2020 [cited 2025 Jan 14]. Available from: https://www.agricultura.gob.ec/magap-ejecuta-proyecto-de-reactivacion-de-la-caficultura-ecuatoriana/

5. Otero Lastra GI. Análisis de la capacitación y asistencia técnica a los productores de café, caso de estudio el noroccidente de Quito 2014-2018 [Internet]. PUCE-Quito; 2019 [cited 2024 Dec 2]. Available from: https://repositorio.puce.edu.ec/handle/123456789/34090

6. Cevallos M, Sandoval-Pillajo L, Caranqui-Sánchez V, Ortega-Bustamante C, Pusdá-Chulde M, García-Santillán I. Morphological Defects Classification in Coffee Beans Based on Convolutional Neural Networks. In: Valencia-García R, Borodulina T, Del Cioppo-Morstadt J, Moran-Castro CE, Vera-Lucio N, editors. Technologies and Innovation. Cham: Springer Nature Switzerland; 2024. p. 3–15. https://doi.org/10.1007/978-3-031-75702-0_1. DOI: https://doi.org/10.1007/978-3-031-75702-0_1

7. Ariza-Sentís M, Vélez S, Martínez-Peña R, Baja H, Valente J. Object detection and tracking in Precision Farming: a systematic review. Comput Electron Agric [Internet]. 2024 Apr 1 [cited 2025 Jun 22];219:108757. https://doi.org/10.1016/J.COMPAG.2024.108757. DOI: https://doi.org/10.1016/j.compag.2024.108757

8. Pusdá-Chulde MR, Salazar-Fierro FA, Sandoval-Pillajo L, Herrera-Granda EP, García-Santillán ID, De Giusti A. Image Analysis Based on Heterogeneous Architectures for Precision Agriculture: A Systematic Literature Review. In 2020. p. 51–70. https://doi.org/10.1007/978-3-030-33614-1_4. DOI: https://doi.org/10.1007/978-3-030-33614-1_4

9. Vinueza K, Sandoval-Pillajo L, Giret-Boggino A, Trejo-España D, Pusdá-Chulde M, García-Santillán I. Automatic weed quantification in potato crops based on a modified convolutional neural network using drone images. Data and Metadata [Internet]. 2025 Feb 13;4(194). https://doi.org/10.56294/dm2025194. DOI: https://doi.org/10.56294/dm2025194

10. Sandoval-Pillajo L, García-Santillán I, Pusdá-Chulde M, Giret A. Weed Detection Based on Deep Learning from UAV Imagery: A Review. Smart Agricultural Technology. 2025. https://doi.org/10.1016/j.atech.2025.101147. DOI: https://doi.org/10.1016/j.atech.2025.101147

11. Chacua B, Garcia I, Rosero P, Suarez L, Ramirez I, Simbana Z, et al. People Identification through Facial Recognition using Deep Learning. 2019 IEEE Latin American Conference on Computational Intelligence, LA-CCI 2019. 2019 Nov 1. https://doi.org/10.1109/LA-CCI47412.2019.9037043. DOI: https://doi.org/10.1109/LA-CCI47412.2019.9037043

12. Montenegro S, Pusdá-Chulde M, Caranqui-Sánchez V, Herrera-Tapia J, Ortega-Bustamante C, García-Santillán I. Android Mobile Application for Cattle Body Condition Score Using Convolutional Neural Networks. In: Narváez FR, Urgilés F, Bastos-Filho TF, Salgado-Guerrero JP, editors. Smart Technologies, Systems and Applications. Cham: Springer Nature Switzerland; 2023. p. 91–105. https://doi.org/10.1007/978-3-031-32213-6_7. DOI: https://doi.org/10.1007/978-3-031-32213-6_7

13. Ulloa F, Sandoval-Pillajo L, Landeta-López P, Granda-Peñafiel N, Pusdá-Chulde M, García-Santillán I. Identification of Diabetic Retinopathy from Retinography Images Using a Convolutional Neural Network. 2025 [cited 2025 Jan 22];121–36. https://doi.org/10.1007/978-3-031-75702-0_10. DOI: https://doi.org/10.1007/978-3-031-75702-0_10

14. Salazar-Fierro F, Cumbal C, Trejo-España D, León-Fernández C, Pusdá-Chulde M, García-Santillán I. Detection of Scoliosis in X-Ray Images Using a Convolutional Neural Network. 2025 [cited 2025 Jan 22];167–83. https://doi.org/10.1007/978-3-031-75702-0_13. DOI: https://doi.org/10.1007/978-3-031-75702-0_13

15. Guaichico E, Pusdá-Chulde M, Ortega-Bustamante M, Granda P, García-Santillán I. Mobile app for real-time academic attendance registration based on MobileFaceNet Convolutional neural network. Data and Metadata. 2025 Feb 13;4:193. https://doi.org/10.56294/dm2025193. DOI: https://doi.org/10.56294/dm2025193

16. Gonzabay Jiménez EF. Procesamiento de imágenes para la clasificación de granos de café por forma y color. 2023 [cited 2025 Mar 20]; Available from: http://repositorio.utmachala.edu.ec/handle/48000/21622

17. Gope HL, Fukai H, Ruhad FM, Barman S. Comparative analysis of YOLO models for green coffee bean detection and defect classification. Sci Rep [Internet]. 2024;14(1). https://doi.org/10.1038/s41598-024-78598-7. DOI: https://doi.org/10.1038/s41598-024-78598-7

18. Arwatchananukul S, Xu D, Charoenkwan P, Aung Moon S, Saengrayap R. Implementing a deep learning model for defect classification in Thai Arabica green coffee beans. Smart Agricultural Technology [Internet]. 2024;9. https://doi.org/10.1016/j.atech.2024.100680. DOI: https://doi.org/10.1016/j.atech.2024.100680

19. Manansala J, Paglinawan C. Classification of Coffea Liberica Quality Using Convolution Neural Networks (Slim-CNN, YOLOv5, and VGG-16). 2024. 1–6 p. https://doi.org/10.1109/ICCCNT61001.2024.10723931. DOI: https://doi.org/10.1109/ICCCNT61001.2024.10723931

20. Nugroho ED, Verdiana M, Algifari MH, Afriansyah A, Firmansyah HB, Rizkita AK, et al. Development of YOLO-Based Mobile Application for Detection of Defect Types in Robusta Coffee Beans. Journal of Applied Informatics and Computing [Internet]. 2025 Jan 16;9(1):153–60. https://doi.org/10.30871/jaic.v9i1.8886. DOI: https://doi.org/10.30871/jaic.v9i1.8886

21. Prabu S, Thanigaivelu PS, Poonkodi S, Anand M. Enhanced Coffee Bean Defect Detection Using Super-Resolution GANs and Deep Learning. 2025 2nd International Conference on Computational Intelligence, Communication Technology and Networking, CICTN 2025 [Internet]. 2025 Jan 1 [cited 2025 May 15];827–32. https://doi.org/10.1109/CICTN64563.2025.10932332. DOI: https://doi.org/10.1109/CICTN64563.2025.10932332

22. Thai HD, Ko HJ, Huh JH. Coffee Bean Defects Automatic Classification Realtime Application Adopting Deep Learning. IEEE Access [Internet]. 2024 Jan 1;12:126503–17. https://doi.org/10.1109/ACCESS.2024.3452552. DOI: https://doi.org/10.1109/ACCESS.2024.3452552

23. Intel. CVAT: Computer Vision Annotation Tool. [Internet]. 2024 [cited 2025 Jul 2]. Available from: https://www.cvat.ai/

24. Lima PM, Reis S. Data Labeling tools for Computer Vision: a Review. 2022 Apr 1 [cited 2025 May 26]; Available from: https://run.unl.pt/handle/10362/135873

25. Roboflow. [Online]. 2025 [cited 2025 Jul 2]. Roboflow: Annotate, Train, Deploy. Available from: https://roboflow.com/

26. Adobe Inc. Software. 2025 [cited 2025 Jul 2]. Adobe Photoshop. Version 25.0, Adobe. Available from: https://photoshop.adobe.com/discover?promoid=LCDWT9XV&lang=es&mv=other&mv2=tab

27. Khanam R, Hussain M. YOLOv11: An Overview of the Key Architectural Enhancements [Internet]. 2024. Available from: https://arxiv.org/abs/2410.17725

28. Sharma A, Kumar V, Longchamps L. Comparative performance of YOLOv8, YOLOv9, YOLOv10, YOLOv11 and Faster R-CNN models for detection of multiple weed species. Smart Agricultural Technology. 2024 Dec 1;9:100648. https://doi.org/10.1016/J.ATECH.2024.100648. DOI: https://doi.org/10.1016/j.atech.2024.100648

29. Aguagallo L, Salazar-Fierro F, García-Santillán J, Posso-Yépez M, Landeta-López P, García-Santillán I. Analysis of Student Performance Applying Data Mining Techniques in a Virtual Learning Environment. International Journal of Emerging Technologies in Learning (iJET) [Internet]. 2023 Jun 7;18(11):175–95. https://doi.org/10.3991/ijet.v18i11.37309. DOI: https://doi.org/10.3991/ijet.v18i11.37309

30. Vila D, Cisneros S, Granda P, Ortega C, Posso-Yépez M, García-Santillán I. Detection of desertion patterns in university students using data mining techniques: A case study. Vol. 895, Communications in Computer and Information Science. 2019. 420–429 p. https://doi.org/10.1007/978-3-030-05532-5_31. DOI: https://doi.org/10.1007/978-3-030-05532-5_31

Downloads

Published

2025-11-25

Issue

Section

Original

How to Cite

1.
Chamorro-Pinchao A, Pusdá-Chulde M, Trejo-España D, Caranqui-Sánchez V, García-Santillán I. Binary classification of defects in multiple coffee beans using lightweight convolutional neural networks for embedded systems. Data and Metadata [Internet]. 2025 Nov. 25 [cited 2025 Dec. 30];4:840. Available from: https://dm.ageditor.ar/index.php/dm/article/view/840