Swin-HSSAM: A green coffee bean grading method by Swin transformer
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.
Authors
- Kang Xiang (ORCID: https://orcid.org/0000-0001-6528-687X)
- Huiyi Deng (ORCID: https://orcid.org/0000-0001-9046-5351)
- Yue Zhang (ORCID: https://orcid.org/0000-0003-4014-7237)
- Tianyun Wang (ORCID: https://orcid.org/0000-0001-5507-7505)
- Jiashun Li (ORCID: https://orcid.org/0000-0001-7463-2500)
- Rui Jiang (ORCID: https://orcid.org/0000-0003-3929-0570)
- Yuqing Zhao (ORCID: https://orcid.org/0009-0000-9912-9637)
- Miao He (ORCID: https://orcid.org/0000-0003-4309-3326)
- Yujie Jiao
- Aoying Jia
Institutions
- Kunming University of Science and Technology (CN)
- Yunnan University (CN)
- Yunnan Agricultural University (CN)
Publication Details
- Journal
- PLoS ONE
- Published
- 2025-05-14
- DOI
- https://doi.org/10.1371/journal.pone.0322198
- Citations
- 4
- Primary Topic
- Advanced Chemical Sensor Technologies
- Type
- article
- Field-Weighted Citation Impact
- 2.70
Funders
- Major Science and Technology Projects in Yunnan Province
- Special Fund for Scientific Innovation Strategy-Construction of High-level Academy of Agriculture Science