Swin-HSSAM: A green coffee bean grading method by Swin transformer
- PMID: 40367122
- PMCID: PMC12077702
- DOI: 10.1371/journal.pone.0322198
Swin-HSSAM: A green coffee bean grading method by Swin transformer
Abstract
A novel shifted window (Swin) Transformer coffee bean grading model called Swin-HSSAM has been proposed to address the challenges of accurately classifying green coffee beans and low identification accuracy. This model integrated the Swin Transformer as the backbone network; fused features from the second, third, and fourth stages using the high-level screening-feature pyramid networks module; and incorporated the selective attention module (SAM) for discriminative power enhancement to enhance the feature outputs before classification. Fusion Loss was employed as the loss function. Experimental results on a proprietary coffee bean dataset demonstrate that the Swin-HSSAM model achieved an average grading accuracy of 96.34% for the three grading as well as the nine defect subdivision levels, outperforming the AlexNet, VGG16, ResNet50, MobileNet-v2, Vision Transformer (ViT), and CrossViT models by 3.86%, 2.56%, 0.44%, 4.05%, 5.36%, and 5.40% percentage points, respectively. Evaluations on a public coffee bean dataset revealed that, compared with the aforementioned models, the Swin-HSSAM model improved the average grading accuracy by 1.01%, 0.13%, 4.75%, 0.85%, 0.73%, and 0.27% percentage points, respectively. These results indicate that the Swin-HSSAM model not only achieved high grading accuracy but also exhibited broad applicability, providing a novel solution for the automated grading and identification of green coffee beans.
Copyright: © 2025 Jiao et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Conflict of interest statement
The authors have declared that no competing interests exist.
Figures















Similar articles
-
Comparative analysis of YOLO models for green coffee bean detection and defect classification.Sci Rep. 2024 Nov 22;14(1):28946. doi: 10.1038/s41598-024-78598-7. Sci Rep. 2024. PMID: 39578522 Free PMC article.
-
SwinCross: Cross-modal Swin transformer for head-and-neck tumor segmentation in PET/CT images.Med Phys. 2024 Mar;51(3):2096-2107. doi: 10.1002/mp.16703. Epub 2023 Sep 30. Med Phys. 2024. PMID: 37776263 Free PMC article.
-
Enhanced Pneumonia Detection in Chest X-Rays Using Hybrid Convolutional and Vision Transformer Networks.Curr Med Imaging. 2025;21:e15734056326685. doi: 10.2174/0115734056326685250101113959. Curr Med Imaging. 2025. PMID: 39806960
-
An improved feature extraction algorithm for robust Swin Transformer model in high-dimensional medical image analysis.Comput Biol Med. 2025 Apr;188:109822. doi: 10.1016/j.compbiomed.2025.109822. Epub 2025 Feb 20. Comput Biol Med. 2025. PMID: 39983364 Review.
-
Efficient brain tumor segmentation using Swin transformer and enhanced local self-attention.Int J Comput Assist Radiol Surg. 2024 Feb;19(2):273-281. doi: 10.1007/s11548-023-03024-8. Epub 2023 Oct 5. Int J Comput Assist Radiol Surg. 2024. PMID: 37796413 Review.
References
-
- Huang J, Li W, Xia B, Hu F. Strategies on how to promote the development of coffee industry with high quality in Yunnan Province [in Chinese]. Trop Agric Sci Technol. 2022;45(03):21-29. https://10.16005/j.cnki.tast.2022.03.005 - DOI
-
- Specialty Coffee Association of America. Specialty Coffee Association of America [Internet]. 2016 May [cited 2024 Nov 4] http://www.scaa.org
-
- Yunnan Provincial Administration for Market Regulation. Small-Berry Coffee Part VII: Green Bean Grading. Yunnan Provincial Administration for Market Regulation. DB53/T 149.7—2023 [Standard, in Chinese]. 2023. Jul 10.
-
- Chang S-J, Huang C-Y. Deep Learning Model for the Inspection of Coffee Bean Defects. Applied Sciences. 2021;11(17):8226. doi: 10.3390/app11178226 - DOI
MeSH terms
Substances
LinkOut - more resources
Full Text Sources