Sinkron : Jurnal dan Penelitian Teknik Informatika
Vol. 9 No. 4 (2025): Articles Research October 2025

Hybrid CNN and KNN Approach for Coffee Bean Quality Identification

Army, Widya Lelisa (Unknown)
Anita, Sri (Unknown)
Ramadhina, Retno (Unknown)



Article Info

Publish Date
26 Oct 2025

Abstract

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.

Copyrights © 2025






Journal Info

Abbrev

sinkron

Publisher

Subject

Computer Science & IT

Description

Scope of SinkrOns Scientific Discussion 1. Machine Learning 2. Cryptography 3. Steganography 4. Digital Image Processing 5. Networking 6. Security 7. Algorithm and Programming 8. Computer Vision 9. Troubleshooting 10. Internet and E-Commerce 11. Artificial Intelligence 12. Data Mining 13. Artificial ...