Siamese networks for few-shot coffee bean defect detection
Defective coffee beans compromise flavor profiles and product quality, necessitating the real-time identification of defects throughout the supply chain. While convolutional neural networks have advanced agricultural image recognition, they remain limited in few-shot classification of fine-grained defects due to dependence on large annotated datasets. This study presents a Siamese neural network approach for few-shot coffee bean defect detection through similarity-based learning. The architecture employs dual ResNet18-based branches (adapted for single-channel 224×224 input, outputting 512-dimensional features) with shared weights, utilizing Euclidean distance for feature matching. A dataset of 3,220 images encompassing sound beans and six defect categories was constructed from samples in Yunnan Province. The model achieved 94.95% accuracy, substantially outperforming traditional CNN (74.35%) and support vector machine (64.28%) approaches. The processing speed of 34 milliseconds per image enables real-time industrial deployment. This approach demonstrates robust generalization under limited sample conditions, offering practical value for resource-constrained production environments in coffee supply chains while reducing reliance on extensive labelled datasets. • Developed a Siamese neural network for efficient coffee bean defect detection. • Achieved over 92% accuracy and F1-score on a custom coffee bean dataset. • Introduced L1 norm feature matching for detecting subtle defect variations. • Outperformed traditional CNN and SVM models in defect classification tasks. • Demonstrated robust generalization under few-shot learning conditions.
Authors
- Xiao Hu (ORCID: https://orcid.org/0000-0003-3994-0385)
- Sunyan Hong
- Xinyu Guo (ORCID: https://orcid.org/0009-0009-4265-011X)
- Jun He (ORCID: https://orcid.org/0000-0002-3199-690X)
- Jing Yu
Institutions
- Kunming University (CN)
- Yunnan University (CN)
Publication Details
- Journal
- LWT
- Published
- 2025-10-17
- DOI
- https://doi.org/10.1016/j.lwt.2025.118631
- Primary Topic
- Smart Agriculture and AI
- Type
- article
- Field-Weighted Citation Impact
- 0.00