Hybrid CNN and KNN Approach for Coffee Bean Quality Identification
DOI:
10.33395/sinkron.v9i4.15366Keywords:
Convolutional Neural Network, K-Nearest Neighbors, Quality Identification, Coffee Beans, Image ClassificationAbstract
This study discusses the integration of Convolutional Neural Network (CNN) and K-Nearest Neighbors (KNN) for the identification of coffee bean quality as an effort to increase the competitiveness of local commodities. CNN is used as a feature extractor to produce an information-rich representation of coffee bean images, while KNN acts as a classifier to classify quality into two classes, namely Good and Defective. The dataset is divided into training, validation, and test data, with a total of 1,190 images obtained from the manual annotation process. The research stages include (1) pre-processing of data in the form of cropping based on bounding boxes, resize to 224×224 pixels, normalization, and data augmentation; (2) feature extraction using pretrained CNN (ResNet18) by eliminating the final classification layer to obtain a 512-dimensional feature vector; and (3) classification using KNN with variations in k values (3, 5, and 7) as well as Euclidean distance metrics. The results of the experiment showed that the CNN+Softmax baseline resulted in an accuracy of 86%, while the CNN+KNN method provided better performance. The k=5 configuration was proven to be optimal with an accuracy of 93.4%, precision, recall, and a balanced F1-score in both classes. The confusion matrix shows that most samples can be classified correctly with a low error rate. These findings are in line with previous research that emphasized the effectiveness of CNN in the extraction of visual features and the advantages of KNN on limited datasets. Thus, this approach can be a practical solution to support an automatic, accurate, and consistent coffee bean quality identification system to increase the competitiveness of local coffee commodities in the global market.
Downloads
References
B, C., S, R., & R, S. (2024). Upgrading Coffee Bean Quality Using K-nearest Algorithm over Future Selection and Extraction to Reduce Dimensionality of Data. 2024 8th International Conference on I-SMAC (IoT in Social, Mobile, Analytics and Cloud) (I-SMAC), 938–943. https://doi.org/10.1109/I-SMAC61858.2024.10714790
Banda, T., Jie, B. Y. W., Farid, A., & Lim, C. S. (2021). Machine Vision and Convolutional Neural Networks for Tool Wear Identification and Classification. Lecture Notes in Electrical Engineering. https://doi.org/10.1007/978-981-33-4597-3_66
Dimaculangan, R. V., & Rosales, M. A. (2024a). Robusta Coffee Bean Defect Classification using Convolutional Neural Network. 2024 7th International Conference on Informatics and Computational Sciences (ICICoS), 66–71. https://doi.org/10.1109/ICICoS62600.2024.10636865
Dimaculangan, R. V., & Rosales, M. A. (2024b). Robusta Coffee Bean Defect Classification using Convolutional Neural Network. 2024 7th International Conference on Informatics and Computational Sciences (ICICoS), 66–71. https://doi.org/10.1109/ICICoS62600.2024.10636865
Duarte, B. S. R., Carneiro, A. D. A., & Sousa, P. M. D. (2024). Coffee bean quality analysis using convolutional neural networks. Anais Do XV Workshop de Sistemas de Informação (WSIS 2024). https://doi.org/10.5753/wsis.2024.33670
Hashmi, M. S. A., Qadri, A. M., Raza, A., Ullah, S., Smerat, A., Kim, C., Syafrudin, M., & Fitriyani, N. L. (2025). VGGBM-Net: A Novel Pixel-Based Transfer Features Engineering for Automated Coffee Bean Diseases Classification. IEEE Access, 13, 83580–83590. https://doi.org/10.1109/ACCESS.2025.3569078
Hendrawan, Y., Widyaningtyas, S., Fauzy, M. R., Sucipto, S., Damayanti, R., Riza, D. F. A., Hermanto, M., & Sandra, S. (2021). Deep Learning to Detect and Classify the Purity Level of Luwak Coffee Green Beans. Pertanika Journal of Science and Technology. https://doi.org/10.47836/pjst.30.1.01
Kholis, M., Nurfadila, A. R., Cahyo, A., Abidin, M., & Wahyudi, I. (2024). Pendampingan Diversifikasi Produk Inovatif Kulit Kopi menjadi Kombucha pada Kelompok Tani Mugi Lestari Desa Kare, Madiun. Jurnal Pengabdian Pada Masyarakat. https://doi.org/10.30653/jppm.v9i4.947
Lee, J.-Y., & Jeong, Y.-S. (2022). Prediction of Defect Coffee Beans Using CNN. 2022 IEEE International Conference on Big Data and Smart Computing (BigComp), 202–205. https://doi.org/10.1109/BigComp54360.2022.00046
Lualhati, A. J. N., Mariano, J. B., Torres, A. E. L., & Fenol, S. D. (2022). Development and Testing of Green Coffee Bean Quality Sorter using Image Processing and Artificial Neural Network. Mindanao Journal of Science and Technology. https://doi.org/10.61310/mndjsteect.1048.22
Mahasin, M. M. (2021). COMPARISON OF CONVOLUTIONAL NEURAL NETWORK ARCHITECTURE FOR CLASSIFICATION OF COFFEE BEAN SPECIES BASED ON DAMPIT COFFEE BEAN VARIATIONS. Proceeding of International Conference on Innovation and Technology (ICIT)2020. https://doi.org/10.21776/ub.jiat.2021.se.01.012
Maulana Iman Pratama, K. (2022). Classification of coffee beans roast maturity levels based on digital image processing color using the KNN and PCA method. International Journal of Scientific and Research Publications. https://doi.org/10.29322/ijsrp.12.12.2022.p13217
Michael, A., & Garonga, M. (2021). Classification model of ‘Toraja’ arabica coffee fruit ripeness levels using convolution neural network approach. ILKOM Jurnal Ilmiah. https://doi.org/10.33096/ilkom.v13i3.861.226-234
Muchtar, K., Hafifah, Y., Febriana, A., Dawood, R., Ahmadiar, A., Bahri, A., Lin, C.-Y., & Yohannes, E. (2025). Edge AI-Based Detection for Defective Coffee Beans Using Deep Learning and Streamlit Framework. IEEE Access, 13, 67977–67992. https://doi.org/10.1109/ACCESS.2025.3561189
Muliawati, A., Ratna, R., & Darwin, D. (2022). Fermentasi Kopi Arabika (Coffea arabica) dengan Sistem Batch menggunakan Inokulum Feses Luwak. Jurnal Ilmiah Mahasiswa Pertanian. https://doi.org/10.17969/jimfp.v7i2.20044
Shao, B., Hou, Y., Huang, N., Wang, W., Lu, X., & Jing, Y. (2022a). Deep Learning based Coffee Beans Quality Screening. 2022 IEEE International Conference on E-Business Engineering (ICEBE), 271–275. https://doi.org/10.1109/ICEBE55470.2022.00054
Shao, B., Hou, Y., Huang, N., Wang, W., Lu, X., & Jing, Y. (2022b). Deep Learning based Coffee Beans Quality Screening. 2022 IEEE International Conference on E-Business Engineering (ICEBE), 271–275. https://doi.org/10.1109/ICEBE55470.2022.00054
Shourie, P., Anand, V., Upadhyay, D., Devliyal, S., Gupta, S., & Shandilya, G. (2024). BeanClassify: Convolutional Neural Networks for Coffee Bean Categorization. 2024 1st International Conference on Advanced Computing and Emerging Technologies (ACET), 1–5. https://doi.org/10.1109/ACET61898.2024.10729994
Sultan, M. A., Furqon, C., Wijaya, F., & Surachman, E. (2021). Peningkatan Literasi Proses Bisnis Pada Kelompok Tani Kopi Buntis Dalam Rangka Penciptaan Keberlanjutan. Aksiologiya: Jurnal Pengabdian Kepada Masyarakat. https://doi.org/10.30651/aks.v5i3.6512
Tesfaye, W., & Fikirie, T. (2024a). An Ensemble Feature Extraction Approach for Ethiopian Coffee Beans Variant Identification. 2024 International Conference on Information and Communication Technology for Development for Africa (ICT4DA), 1–6. https://doi.org/10.1109/ICT4DA62874.2024.10777203
Tesfaye, W., & Fikirie, T. (2024b). An Ensemble Feature Extraction Approach for Ethiopian Coffee Beans Variant Identification. 2024 International Conference on Information and Communication Technology for Development for Africa (ICT4DA), 1–6. https://doi.org/10.1109/ICT4DA62874.2024.10777203
Wang, P., Tseng, H.-W., Chen, T.-C., & Hsia, C.-H. (2021). Deep Convolutional Neural Network for Coffee Bean Inspection. Sensors and Materials. https://doi.org/10.18494/sam.2021.3277
Downloads
How to Cite
Issue
Section
License
Copyright (c) 2025 Widya Lelisa Army, Sri Anita, Retno Ramadhina

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.


Moraref
PKP Index
Indonesia OneSearch
OCLC Worldcat
Index Copernicus
Scilit




















