The Lightweight Swin Transformer for Salinity Degree Classification in a Natural Saline Soil Environment
Abstract
1. Introduction
- We propose a lightweight Transformer model, Swin-KD, which integrates Swin Transformer with a token-based knowledge distillation framework to enhance classification accuracy while significantly reducing parameter count.
- A novel distillation strategy is introduced, where distillation tokens interact with class tokens via attention mechanisms, enabling effective knowledge transfer from the teacher model and improving both efficiency and performance.
- Experimental results on real-world saline soil datasets demonstrate that Swin-KD outperforms baseline models in both accuracy and inference speed, showing strong potential for practical applications in soil salinity monitoring.
2. Materials and Methods
2.1. Dataset Collection
2.2. Overall Architecture
2.3. Teacher Model
2.3.1. Shifted Window in Teacher Model
2.3.2. Self-Attention in the Teacher Model
2.4. Student Model
Based-Token Distillation in the Student Model
2.5. Evaluation Metrics
3. Results
3.1. Implementation Details
3.2. Image Classification on the Saline Soil Dataset
3.3. Results Visualization
4. Discussion
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Wang, J.; Ding, J.; Yu, D.; Ma, X.; Zhang, Z.; Ge, X.; Teng, D.; Li, X.; Liang, J.; Lizaga, I.; et al. Capability of Sentinel-2 MSI Data for Monitoring and Mapping of Soil Salinity in Dry and Wet Seasons in the Ebinur Lake Region, Xinjiang, China. Geoderma 2019, 353, 172–187. [Google Scholar] [CrossRef]
- Li, J.; Gao, Y.; Zhang, X.; Tian, P.; Li, J.; Tian, Y. Comprehensive Comparison of Different Saline Water Irrigation Strategies for Tomato Production: Soil Properties, Plant Growth, Fruit Yield and Fruit Quality. Agric. Water Manag. 2019, 213, 521–533. [Google Scholar] [CrossRef]
- Chen, H.; Tao, L.; Shi, J.; Han, X.; Cheng, X. Exogenous Salicylic Acid Signal Reveals an Osmotic Regulatory Role in Priming the Seed Germination of Leymus Chinensis under Salt-Alkali Stress. Environ. Exp. Bot. 2021, 188, 104498. [Google Scholar] [CrossRef]
- Zhang, K.; Chang, L.; Li, G.; Li, Y. Advances and Future Research in Ecological Stoichiometry under Saline-Alkali Stress. Environ. Sci. Pollut. R. 2023, 30, 5475–5486. [Google Scholar] [CrossRef] [PubMed]
- Bannari, A.; El-Battay, A.; Bannari, R.; Rhinane, H. Sentinel-MSI VNIR and SWIR Bands Sensitivity Analysis for Soil Salinity Discrimination in an Arid Landscape. Remote Sens. 2018, 10, 855. [Google Scholar] [CrossRef]
- Zhang, Z.; Li, X.; Ren, J.; Zhou, S. Study on the Drying Process and the Influencing Factors of Desiccation Cracking of Cohesive Soda Saline-Alkali Soil in the Songnen Plain, China. Agriculture 2023, 13, 1153. [Google Scholar] [CrossRef]
- Escorcia-Gutierrez, J.; Gamarra, M.; Soto-Diaz, R.; Pérez, M.; Madera, N.; Mansour, R.F. Intelligent Agricultural Modelling of Soil Nutrients and pH Classification Using Ensemble Deep Learning Techniques. Agriculture 2022, 12, 977. [Google Scholar] [CrossRef]
- Padmapriya, J.; Sasilatha, T. Deep Learning Based Multi-Labelled Soil Classification and Empirical Estimation toward Sustainable Agriculture. Eng. Appl. Artif. Intell. 2023, 119, 105690. [Google Scholar] [CrossRef]
- Lanjewar, M.G.; Gurav, O.L. Convolutional Neural Networks Based Classifications of Soil Images. Multimed. Tools Appl. 2022, 81, 10313–10336. [Google Scholar] [CrossRef]
- Ferrer-Ferrer, M.; Ruiz-Hidalgo, J.; Gregorio, E.; Vilaplana, V.; Morros, J.R.; Gené-Mola, J. Simultaneous Fruit Detection and Size Estimation Using Multitask Deep Neural Networks. Biosyst. Eng. 2023, 233, 63–75. [Google Scholar] [CrossRef]
- Mia, S.; Tanabe, R.; Habibi, L.N.; Hashimoto, N.; Homma, K.; Maki, M.; Matsui, T.; Tanaka, T.S.T. Multimodal Deep Learning for Rice Yield Prediction Using UAV-Based Multispectral Imagery and Weather Data. Remote Sens. 2023, 15, 2511. [Google Scholar] [CrossRef]
- Lu, J.; Tan, L.; Jiang, H. Review on Convolutional Neural Network (CNN) Applied to Plant Leaf Disease Classification. Agriculture 2021, 11, 707. [Google Scholar] [CrossRef]
- Hasan, A.S.M.M.; Sohel, F.; Diepeveen, D.; Laga, H.; Jones, M.G.K. A Survey of Deep Learning Techniques for Weed Detection from Images. Comput. Electron. Agric. 2021, 184, 106067. [Google Scholar] [CrossRef]
- Moazzam, S.I.; Nawaz, T.; Qureshi, W.S.; Khan, U.S.; Tiwana, M.I. A W-Shaped Convolutional Network for Robust Crop and Weed Classification in Agriculture. Precis. Agric. 2023, 24, 2002–2018. [Google Scholar] [CrossRef]
- Farrell, M.; Leizica, E.; Gili, A.; Noellemeyer, E. Identification of Management Zones with Different Potential Moisture Availability for Sustainable Intensification of Dryland Agriculture. Precis. Agric. 2023, 24, 1116–1131. [Google Scholar] [CrossRef]
- De Castro Pereira, R.; Hirose, E.; Ferreira De Carvalho, O.L.; Da Costa, R.M.; Borges, D.L. Detection and Classification of Whiteflies and Development Stages on Soybean Leaves Images Using an Improved Deep Learning Strategy. Comput. Electron. Agric. 2022, 199, 107132. [Google Scholar] [CrossRef]
- Waheed, A.; Goyal, M.; Gupta, D.; Khanna, A.; Hassanien, A.E.; Pandey, H.M. An Optimized Dense Convolutional Neural Network Model for Disease Recognition and Classification in Corn Leaf. Comput. Electron. Agric. 2020, 175, 105456. [Google Scholar] [CrossRef]
- Yan, C.; Li, Z.; Zhang, Z.; Sun, Y.; Wang, Y.; Xin, Q. High-Resolution Mapping of Paddy Rice Fields from Unmanned Airborne Vehicle Images Using Enhanced-TransUnet. Comput. Electron. Agric. 2023, 210, 107867. [Google Scholar] [CrossRef]
- Hayıt, T.; Erbay, H.; Varçın, F.; Hayıt, F.; Akci, N. The Classification of Wheat Yellow Rust Disease Based on a Combination of Textural and Deep Features. Multimed. Tools Appl. 2023, 82, 47405–47423. [Google Scholar] [CrossRef]
- Paul, S.G.; Biswas, A.A.; Saha, A.; Zulfiker, S.; Ritu, N.A.; Zahan, I.; Rahman, M.; Islam, M.A. A Real-Time Application-Based Convolutional Neural Network Approach for Tomato Leaf Disease Classification. Array 2023, 19, 100313. [Google Scholar] [CrossRef]
- Kumar, V.S.; Jaganathan, M.; Viswanathan, A.; Umamaheswari, M.; Vignesh, J. Rice Leaf Disease Detection Based on Bidirectional Feature Attention Pyramid Network with YOLO v5 Model. Environ. Res. Commun. 2023, 5, 065014. [Google Scholar] [CrossRef]
- Sunil, C.K.; Jaidhar, C.D.; Patil, N. Tomato Plant Disease Classification Using Multilevel Feature Fusion with Adaptive Channel Spatial and Pixel Attention Mechanism. Expert Syst. Appl. 2023, 228, 120381. [Google Scholar] [CrossRef]
- Gao, L.; Liu, H.; Yang, M.; Chen, L.; Wan, Y.; Xiao, Z.; Qian, Y. STransFuse: Fusing Swin Transformer and Convolutional Neural Network for Remote Sensing Image Semantic Segmentation. IEEE J. Sel. Top. Appl. Earth Obs. Remote Sens. 2021, 14, 10990–11003. [Google Scholar] [CrossRef]
- Gao, L.; Zhang, J.; Yang, C.; Zhou, Y. Cas-VSwin Transformer: A Variant Swin Transformer for Surface-Defect Detection. Comput. Ind. 2022, 140, 103689. [Google Scholar] [CrossRef]
- Wang, Z.; Zhao, J.; Zhang, R.; Li, Z.; Lin, Q.; Wang, X. UATNet: U-Shape Attention-Based Transformer Net for Meteorological Satellite Cloud Recognition. Remote Sens. 2021, 14, 104. [Google Scholar] [CrossRef]
- Mazuz, E.; Shtar, G.; Kutsky, N.; Rokach, L.; Shapira, B. Pretrained Transformer Models for Predicting the Withdrawal of Drugs from the Market. Bioinformatics 2023, 39, btad519. [Google Scholar] [CrossRef] [PubMed]
- Ji, Z.; Lee, N.; Frieske, R.; Yu, T.; Su, D.; Xu, Y.; Ishii, E.; Bang, Y.J.; Madotto, A.; Fung, P. Survey of Hallucination in Natural Language Generation. ACM Comput. Surv. 2023, 55, 248. [Google Scholar] [CrossRef]
- Devlin, J.; Chang, M.W.; Lee, K.; Toutanova, K. BERT: Pre-Training of Deep Bidirectional Transformers for Language Understanding. arXiv 2019, arXiv:1810.04805. [Google Scholar] [CrossRef]
- Liu, Z.; Lin, Y.; Cao, Y.; Hu, H.; Wei, Y.; Zhang, Z.; Lin, S.; Guo, B. Swin Transformer: Hierarchical Vision Transformer Using Shifted Windows. In Proceedings of the 2021 IEEE/CVF International Conference on Computer Vision (ICCV), Montreal, QC, Canada, 10–17 October 2021; pp. 9992–10002. [Google Scholar]
- Dosovitskiy, A.; Beyer, L.; Kolesnikov, A.; Weissenborn, D.; Zhai, X.; Unterthiner, T.; Dehghani, M.; Minderer, M.; Heigold, G.; Gelly, S.; et al. An Image Is Worth 16x16 Words: Transformers for Image Recognition at Scale. arXiv 2021, arXiv:2010.11929. [Google Scholar] [CrossRef]
- Wang, W.; Xie, E.; Li, X.; Fan, D.-P.; Song, K.; Liang, D.; Lu, T.; Luo, P.; Shao, L. Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions. arXiv 2021, arXiv:2102.12122. [Google Scholar] [CrossRef]
- Han, K.; Xiao, A.; Wu, E.; Guo, J.; Xu, C.; Wang, Y. Transformer in Transformer. arXiv 2021, arXiv:2103.00112. [Google Scholar] [PubMed]
- Yuan, L.; Chen, Y.; Wang, T.; Yu, W.; Shi, Y.; Jiang, Z.; Tay, F.E.; Feng, J.; Yan, S. Tokens-to-Token ViT: Training Vision Transformers from Scratch on ImageNet. arXiv 2021, arXiv:2101.11986. [Google Scholar]
- Chu, X.; Tian, Z.; Zhang, B.; Wang, X.; Shen, C. Conditional Positional Encodings for Vision Transformers. arXiv 2023, arXiv:2102.10882. [Google Scholar] [CrossRef]
- He, K.; Zhang, X.; Ren, S.; Sun, J. Deep Residual Learning for Image Recognition. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, USA, 27–30 June 2016; pp. 770–778. [Google Scholar]
- Ramachandran, P.; Parmar, N.; Vaswani, A.; Bello, I.; Levskaya, A.; Shlens, J. Stand-Alone Self-Attention in Vision Models. arXiv 2019, arXiv:1906.05909. [Google Scholar]
- Zhao, H.; Jia, J.; Koltun, V. Exploring Self-Attention for Image Recognition. arXiv 2020, arXiv:2004.13621. [Google Scholar] [CrossRef]
- Hu, H.; Zhang, Z.; Xie, Z.; Lin, S. Local Relation Networks for Image Recognition. arXiv 2019, arXiv:1904.11491. [Google Scholar] [CrossRef]
- Hinton, G.; Vinyals, O.; Dean, J. Distilling the Knowledge in a Neural Network. arXiv 2015, arXiv:1503.02531. [Google Scholar] [CrossRef]
- Romero, A.; Ballas, N.; Kahou, S.E.; Chassang, A.; Gatta, C.; Bengio, Y. FitNets: Hints for Thin Deep Nets. arXiv 2015, arXiv:1412.6550. [Google Scholar] [CrossRef]
- Yuan, L.; Tay, F.E.H.; Li, G.; Wang, T.; Feng, J. Revisiting Knowledge Distillation via Label Smoothing Regularization. arXiv 2021, arXiv:1909.11723. [Google Scholar] [CrossRef]
- Wei, L.; Xiao, A.; Xie, L.; Chen, X.; Zhang, X.; Tian, Q. Circumventing Outliers of AutoAugment with Knowledge Distillation. arXiv 2020, arXiv:2003.11342. [Google Scholar] [CrossRef]
- Abnar, S.; Dehghani, M.; Zuidema, W. Transferring Inductive Biases through Knowledge Distillation. arXiv 2020, arXiv:2006.00555. [Google Scholar] [CrossRef]
- Szegedy, C.; Vanhoucke, V.; Ioffe, S.; Shlens, J.; Wojna, Z. Rethinking the Inception Architecture for Computer Vision. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, USA, 27–30 June 2016; pp. 2818–2826. [Google Scholar]
- Kingma, D.P.; Ba, J. Adam: A Method for Stochastic Optimization. arXiv 2017, arXiv:1412.6980. [Google Scholar] [CrossRef]
- Simonyan, K.; Zisserman, A. Very Deep Convolutional Networks for Large-Scale Image Recognition. arXiv 2015, arXiv:1409.1556. [Google Scholar] [CrossRef]
- Bañón, S.; Álvarez, S.; Bañón, D.; Ortuño, M.F.; Sánchez-Blanco, M.J. Assessment of Soil Salinity Indexes Using Electrical Conductivity Sensors. Sci. Hortic. 2021, 285, 110171. [Google Scholar] [CrossRef]
- Gad, M.M.E.-S.; Mohamed, M.H.A.; Mohamed, M.R. Soil Salinity Mapping Using Remote Sensing and GIS. Geomatica 2021, 75, 1–15. [Google Scholar] [CrossRef]
Low | Middle | High | Total | |
---|---|---|---|---|
train | 850 | 850 | 850 | 2550 |
validation | 200 | 200 | 200 | 600 |
test | 100 | 100 | 100 | 300 |
total | 1150 | 1150 | 1150 | 3450 |
Models | Recall (%) | F1_Score (%) | Precision (%) | Accuracy (%) | Params (M) | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Low | Middle | High | Low | Middle | High | Low | Middle | High | |||
AlexNet | 94.97 | 83.33 | 86.30 | 96.92 | 82.44 | 85.52 | 98.95 | 81.57 | 84.75 | 88.24 | 61.12 |
DensenNet | 100.00 | 93.01 | 88.58 | 98.27 | 90.81 | 91.94 | 96.60 | 88.71 | 95.56 | 93.70 | 14.16 |
ResNet152 | 100.00 | 87.63 | 95.89 | 99.25 | 91.06 | 93.54 | 98.51 | 94.76 | 91.30 | 94.70 | 58.15 |
Efficiennet | 99.49 | 85.48 | 94.06 | 98.75 | 89.32 | 91.35 | 98.01 | 93.52 | 88.79 | 93.21 | 145.00 |
InceptionV3 | 99.49 | 87.09 | 89.04 | 98.75 | 87.09 | 89.65 | 98.01 | 87.09 | 90.27 | 91.88 | 24.36 |
VGG16 | 100.00 | 88.17 | 91.78 | 98.27 | 89.86 | 91.78 | 96.60 | 91.62 | 91.78 | 93.37 | 117.51 |
VGG19 | 98.49 | 87.09 | 92.23 | 98.49 | 88.28 | 91.19 | 98.49 | 89.50 | 90.17 | 92.71 | 139.59 |
MobileNetV3 | 98.49 | 88.09 | 89.04 | 98.25 | 88.09 | 89.15 | 98.01 | 88.09 | 89.27 | 91.68 | 5.40 |
EfficientFormer | 99.49 | 88.14 | 95.89 | 99.04 | 91.06 | 93.43 | 98.61 | 94.86 | 91.10 | 94.60 | 13.80 |
Vision Transformer | 92.49 | 5.31 | 16.27 | 50.45 | 5.38 | 14.95 | 34.68 | 5.45 | 13.82 | 38.63 | 85.80 |
Swin Transformer | 100.00 | 94.52 | 96.70 | 96.12 | 96.10 | 96.10 | 98.52 | 95.71 | 95.31 | 96.00 | 27.50 |
Swin-KD | 100.00 | 94.06 | 96.93 | 99.44 | 95.43 | 96.61 | 98.89 | 96.00 | 96.31 | 96.30 | 5.53 |
Model | Acc (%) | Confidence Interval (95%) |
---|---|---|
AlexNet | 88.24 | (0.8182, 0.9466) |
DensenNet | 93.70 | (0.8897, 0.9843) |
ResNet152 | 94.70 | (0.9044, 0.9896) |
Efficiennet | 93.21 | (0.8831, 0.9811) |
InceptionV3 | 91.88 | (0.8642, 0.9734) |
VGG16 | 93.37 | (0.8856, 0.9818) |
VGG19 | 92.71 | (0.8768, 0.9774) |
MobileNetV3 | 91.68 | (0.8627, 0.9709) |
EfficientFormer | 94.60 | (0.9017, 0.9903) |
Vision Transformer | 38.63 | (0.2915, 0.4811) |
Swin Transformer | 96.00 | (0.9215, 0.9985) |
Swin-KD | 96.30 | (0.9262, 0.9998) |
Model | Test1 | Test2 | Test3 | Test4 | Test5 | Average |
---|---|---|---|---|---|---|
AlexNet | 12.16 | 11.07 | 12.34 | 12.36 | 11.23 | 11.832 |
DensenNet | 11.88 | 11.61 | 11.89 | 11.83 | 11.66 | 11.774 |
ResNet152 | 12.33 | 11.20 | 12.24 | 12.32 | 11.12 | 11.842 |
Efficiennet | 12.25 | 11.05 | 12.36 | 11.93 | 10.98 | 12.742 |
InceptionV3 | 12.51 | 11.30 | 12.36 | 12.46 | 11.27 | 11.980 |
VGG16 | 13.13 | 11.87 | 13.40 | 13.26 | 12.05 | 12.742 |
VGG19 | 13.07 | 12.01 | 13.44 | 13.27 | 11.84 | 12.726 |
Vision Transformer | 13.02 | 11.77 | 12.91 | 13.07 | 11.71 | 12.496 |
Swin Transformer | 12.52 | 11.22 | 12.60 | 12.21 | 11.28 | 11.966 |
Swin-KD | 12.11 | 10.90 | 11.97 | 12.19 | 10.75 | 11.584 |
Model | Acc (%) | Param (M) |
---|---|---|
AlexNet | 57.2 | 61.0 |
DensenNet | 74.9 | 8.0 |
ResNet152 | 76.2 | 60.2 |
EfficientNet | 77.1 | 5.0 |
InceptionV3 | 77.9 | 23.8 |
VGG16 | 71.3 | 138.4 |
VGG19 | 71.6 | 143.7 |
MobileNetV3 | 75.2 | 5.4 |
EfficientFormer | 81.0 | 13.8 |
Vision Transformer | 77.9 | 86.5 |
Swin Transformer | 81.3 | 27.5 |
Swin-KD | 81.8 | 5.53 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Wang, R.; Yang, L.; Yang, Q.; Cao, C. The Lightweight Swin Transformer for Salinity Degree Classification in a Natural Saline Soil Environment. Agronomy 2025, 15, 1958. https://doi.org/10.3390/agronomy15081958
Wang R, Yang L, Yang Q, Cao C. The Lightweight Swin Transformer for Salinity Degree Classification in a Natural Saline Soil Environment. Agronomy. 2025; 15(8):1958. https://doi.org/10.3390/agronomy15081958
Chicago/Turabian StyleWang, Ruoxi, Ling Yang, Qiliang Yang, and Chunhao Cao. 2025. "The Lightweight Swin Transformer for Salinity Degree Classification in a Natural Saline Soil Environment" Agronomy 15, no. 8: 1958. https://doi.org/10.3390/agronomy15081958
APA StyleWang, R., Yang, L., Yang, Q., & Cao, C. (2025). The Lightweight Swin Transformer for Salinity Degree Classification in a Natural Saline Soil Environment. Agronomy, 15(8), 1958. https://doi.org/10.3390/agronomy15081958