SpinachXAI-Rec: a multi-stage explainable AI framework for spinach freshness classification and consumer recommendation
Document Type
Article
Publication Title
Scientific Reports
Abstract
Leafy vegetables such as spinach are among the most important components in a nutritious diet but are highly perishable and susceptible to premature spoilage. Traditional practices in determining freshness have been qualitative and time-consuming and have consistently led to defective consumption decisions with unintended consequences on human health. To this issue, we introduce SpinachXAI-Rec, a multistage framework that is enabled by AI and is capable of automating the classification of spinach freshness and providing consumer recommendations. This framework is based on understandable deep learning. To guarantee class balance and feature diversity, a dataset consisting of 4005 original images of three spinach varieties (Malabar, Red, and Water) was expanded to 12,000 images (2000 per class across six categories: fresh and non-fresh). We trained three CNN architectures, DenseNet121, ResNet50, and EfficientNetB0, on the Stage 1 augmented dataset. In performance, we saw DenseNet121 significantly outperform with 96% classification accuracy compared to ResNet50 (53%) and EfficientNetB0 (17%). Stage 2 improved representation of features by incorporating DenseNet121 embeddings and ViT-B/16 and Swin Transformer attention mechanisms. DenseNet121 + ViT-B/16 obtained an F1-score of 0.95, which was further optimised to 0.97 in Stage 3 using a multiclass SVM classifier. GradCAM++ and LIME were employed to incorporate interpretability during Stage 4. LIME provided transparent explanations of the significance of class-specific features, while GradCAM++ effectively highlighted disease-affected or spoilt regions. The most effective model (DenseNet121 + ViT + SVM) also obtained a Dice coefficient of 0.89 and an IoU of 0.82, which confirms the precision of localisation and segmentation. Finally, Stage 5 introduces a clinical recommender system that is based on rules and relates prediction confidence to real-world categories: Eatable, Eatable with Caution, or Not Eatable. This AI-driven recommendation assists food purveyors and consumers in making health-conscious, well-informed decisions. SpinachXAI-Rec is a significant advancement in the development of safer food systems, as it provides interpretable AI for the purpose of freshness validation and actionable consumption recommendations, thereby empowering both consumers and industry stakeholders.
DOI
10.1038/s41598-025-19804-y
Publication Date
12-1-2025
Recommended Citation
Raju, Akella S.Narasimha; Sujatha, G.; Gatla, Ranjit Kumar; and Ankalaki, Shilpa, "SpinachXAI-Rec: a multi-stage explainable AI framework for spinach freshness classification and consumer recommendation" (2025). Open Access archive. 11952.
https://impressions.manipal.edu/open-access-archive/11952