Abstract
In this paper, we introduce a novel application domain which is first of its kind to the vision transformer based deep learning model. We propose a model for ripeness grading of mangoes using vision transformers. Our approach divides the mango image into patches, which are then linearly projected and transformed into a sequence of embeddings. To retain positional information, positional encodings are added to these patches. Additionally, for image classification, learnable class tokens are included at the start of this sequence of embeddings. The resulting sequence is passed through multiple multi-head self-attention (MSA) layers to capture both local and global dependencies and to interpret the spatial relationships among patches. Further to improve the classification performance, we explored five data augmentation strategies to synthetically induce additional data for training. Moreover, different vision transformer models are investigated with and without pre-trained weights while training of neural network. This study is demonstrated through an experimentation on a dataset of 979 images of Alphonso mango variety belonging to four classes particularly, unripen, ripened, over-ripened without internal defects and over-ripened with internal defects. The vision transformers viz., ViT_Base_16, ViT_Large_16 and ViT_Huge_14 is considered for experimentation. The results of the experimentation demonstrated that, the ViT_Huge_14 with pre-trained weight and with data augmentation gives average accuracy of 92.78%, which is better than 85.40% quoted in the existing work of mango grading using conventional machine learning on the same dataset (Raghavendra et al., 2020).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
Amruta, S., & Wakode, M. (2021) “Ripeness, Size and Shape based Automated Mango Grading using Image Processing and Machine Learning Techniques” International Journal of current engineering and technology INPRESSCO: E-ISSN 2277–4106.
Agilandeeswari, L., Prabukumar, M., & Goel, S. (2017). Automatic grading system for mangoes using multiclass SVM classifier. International Journal of Pure and Applied Mathematics, 116(23), 515-523.
Bakar, M. A., Abdullah, A. H., Rahim, N. A., Yazid, H., Saad, F. S. A., & Ahmad, K. (2020, September). Development of ripeness indicator for quality assessment of harumanis mango by using image processing technique. In IOP Conference Series: Materials Science and Engineering (Vol. 932, No. 1, p. 012087). IOP Publishing.
Bhole, V., & Kumar, A. (2020, October). Mango quality grading using deep learning technique: Perspectives from agriculture and food industry. In Proceedings of the 21st annual conference on information technology education (pp. 180–186).
Bazi, Y., Bashmal, L., Rahhal, M. M. A., Dayil, R. A., & Ajlan, N. A. (2021). Vision transformers for remote sensing image classification. Remote Sensing, 13(3), 516.
Chen, Z., Xie, L., Niu, J., Liu, X., Wei, L., & Tian, Q. (2021). Visformer: The vision-friendly transformer. In Proceedings of the IEEE/CVF international conference on computer vision (pp. 589–598
Chhabra, M., Gupta, A., Mehrotra, P., & Reel, S. (2012). Automated detection of fully and partially riped mango by machine vision. In Proceedings of the International Conference on Soft Computing for Problem Solving (SocProS 2011) December 20–22, 2011: Volume 2 (pp. 153–164). Springer India.
Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., ... & Houlsby, N. (2020). An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929.
Devlin, J., Chang, M. W., Lee, K., & Toutanova, K. (2018). Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805.
Dhanya, V. G., Subeesh, A., Kushwaha, N. L., Vishwakarma, D. K., Kumar, T. N., Ritika, G., & Singh, A. N. (2022). Deep learning based computer vision approaches for smart agricultural applications. Artificial Intelligence in Agriculture.
Gururaj, N., Vinod, V., & Vijayakumar, K. (2022). Deep grading of mangoes using Convolutional Neural Network and Computer Vision. Multimedia Tools and Applications, 1–26.
Khan, A., Hassan, T., Shafay, M., Fahmy, I., Werghi, N., Seneviratne, L., & Hussain, I. (2023). Convolutional Transformer for Autonomous Recognition and Grading of Tomatoes Under Various Lighting, Occlusion, and Ripeness Conditions. arXiv preprint arXiv:2307.01530.
Khan, A., Hassan, T., Shafay, M., Fahmy, I., Werghi, N., Mudigansalage, S., & Hussain, I. (2023). Tomato maturity recognition with convolutional transformers. Scientific Reports, 13(1), 22885.
Khoje, S., & Bodhe, S. (2012). Performance comparison of Fourier transform and its derivatives as shape descriptors for mango grading. International Journal of Computer Applications, 53(3), 17-22.
Khoje, Suchitra, Bodhe, S.K., 2015. Comparative performance evaluation of fast discrete curvelet transform and color texture moments as texture features for fruit skin damage detection. Springer J. Food Sci. Technol. 52, 6914–6926.
Knott, M., Perez-Cruz, F., & Defraeye, T. (2023). Facilitated machine learning for image-based fruit quality assessment. Journal of Food Engineering, 345, 111401.
Nandi, C. S., Tudu, B., & Koley, C. (2014). Machine vision based techniques for automatic mango fruit sorting and grading based on maturity level and size. Sensing technology: current status and future trends II, 27-46
Nayeli, V. Rivera, José, J. Chanona Pérez, Reynold, F. Rebollo, José, Blasco, Georgina, C. Domínguez, de María, J.P. Flores, Israel, A. Vázquez, (2012). “Description of maturity stages of mango ‘Manila’ by image analysis and ripening index” CIGR-Ageng Conference www2.atb-potsdam.
Othman, M., Bakar, M. N. A., Ahmad, K. A., & Razak, T. R. (2014). Fuzzy ripening mango index using RGB colour sensor model. Researchers World, 5(2), 1.
Parez, S., Dilshad, N., Alghamdi, N. S., Alanazi, T. M., & Lee, J. W. (2023). Visual intelligence in precision agriculture: Exploring plant disease detection via efficient vision transformers. Sensors, 23(15), 6949.
Rizzo, M., Marcuzzo, M., Zangari, A., Gasparetto, A., & Albarelli, A. (2023). Fruit ripeness classification: A survey. Artificial Intelligence in Agriculture.
Raghavendra, A., Guru, D. S., Rao, M. K., & Sumithra, R. (2020). Hierarchical approach for ripeness grading of mangoes. Artificial Intelligence in Agriculture, 4, 243-252.
Supekar, A., & Wakode, M. (2020). Computer vision based automated mango grading–a review. J. Postharvest Techno, 8(1), 23-37.
Sa’ad, F. S. A., Ibrahim, M. F., Shakaff, A. M., Zakaria, A., & Abdullah, M. Z. (2015). Shape and weight grading of mangoes using visible imaging. Computers and Electronics in Agriculture, 115, 51-56.
Salunkhe, R. P., & Patil, A. A. (2015, December). Image processing for mango ripening stage detection: RGB and HSV method. In 2015 Third International Conference on Image Information Processing (ICIIP) (pp. 362–365). IEEE.
Shahi, T. B., Sitaula, C., Neupane, A., & Guo, W. (2022). Fruit classification using attention-based MobileNetV2 for industrial applications. Plos one, 17(2), e0264586.
Thai, H. T., Le, K. H., & Nguyen, N. L. T. (2023). FormerLeaf: An efficient vision transformer for Cassava Leaf Disease detection. Computers and Electronics in Agriculture, 204, 107518.
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., ... & Polosukhin, I. (2017). Attention Is All You Need. Advances in Neural Information Processing System, 30.
Vyas, A. M., Talati, B., & Naik, S. (2014). Quality inspection and classification of mangoes using color and size features. International Journal of Computer Applications, 98(1).
Wang, Y., Chen, Y., & Wang, D. (2022). Convolution network enlightened transformer for regional crop disease classification. Electronics, 11(19), 3174.
Xiao, B., Nguyen, M., & Yan, W. Q. (2023). Fruit ripeness identification using transformers. Applied Intelligence, 1–12.
Yu, S., Xie, L., & Huang, Q. (2023). Inception convolutional vision transformers for plant disease identification. Internet of Things, 21, 100650.
Zheng, B., & Huang, T. (2021). Mango grading system based on optimized Convolutional Neural Network. Mathematical Problems in Engineering, 2021, 1-11.
Acknowledgments
The authors would like to thank Ministry of Social Justice and Empowerment, Government of India for the financial support. The authors also wish to acknowledge Dr.Anitha Raghavendra for her generous provision of the dataset used in this study.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2025 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Guru, D.S., Nandini, D. (2025). Mangoes Ripeness Grading: Vision Based Approach. In: Antonacopoulos, A., Chaudhuri, S., Chellappa, R., Liu, CL., Bhattacharya, S., Pal, U. (eds) Pattern Recognition. ICPR 2024. Lecture Notes in Computer Science, vol 15325. Springer, Cham. https://doi.org/10.1007/978-3-031-78389-0_5
Download citation
DOI: https://doi.org/10.1007/978-3-031-78389-0_5
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-78388-3
Online ISBN: 978-3-031-78389-0
eBook Packages: Computer ScienceComputer Science (R0)