DAC-Grad-CAM: Defect-aware explainable AI for automated mango quality classification
Deep learning models achieve high fruit classification accuracy but lack interpretability; standard Grad-CAM produces diffuse attention without defect-specific localization. Existing explainable AI (XAI) methods for fruit grading rely on qualitative visual inspection, offering no quantitative validation of defect alignment, thereby limiting trust and regulatory acceptance in commercial quality control. This study presents an explainable mango classification framework that integrates classification performance with quantitative interpretability analysis through Defect-Aware Contrastive Grad-CAM (DAC-Grad-CAM). A new method that multiplicatively fuses gradient-based attention with an unsupervised LAB color-space bruise prior. A two-stage pipeline combining YOLO-11n detection with four classification architectures (ResNet18, MobileNetV3, VGG16, and a custom CNN). Evaluated on a three-class mango dataset (premium, class 1, class 2). Transfer-learning architectures substantially outperformed the custom CNN (ResNet18: 97.8%, VGG16: 97.6%, MobileNetV3: 96.5% vs 75.4%), a 22–23 percentage-point gap, with premium-class precision > 0.995. DAC-Grad-CAM produced the most concentrated explanations (entropy 10.02 versus 10.27 for Grad-CAM and 10.18 for SHAP). Validated against 50 manually annotated pixel-level bruise masks, it improved peak localization over standard Grad-CAM (pointing-game accuracy 0.561 versus 0.439) and, on the transfer-learning backbones, exceeded SHAP (0.659 versus 0.615) while requiring 34 ms per region against 4220 ms, a 124-fold reduction in cost. The Defect Focus Score (DFS) enabled task-specific validation, and the agreement between gradient and perturbation-based explanations (r = 0.68–0.75, p < 0.001) confirmed that the localized features are task-genuine rather than method-specific artifacts. Under controlled perturbations emulating varied lighting, resolution, defocus, compression, and occlusion, defect-focused attention remained stable while classification accuracy degraded, and end-to-end throughput reached 17.4 fruit s⁻ 1 . The framework supports a confidence-based human-AI workflow (margin > 0.95, DFS > 0.37, r > 0.60) for trustworthy automated quality control in post-harvest operations.
Authors
- Zhanjiang Zhu
- Shahram Hamza Manzoor
- Mustafa Mhamed (ORCID: https://orcid.org/0000-0002-3106-669X)
- Rashed Ahmed (ORCID: https://orcid.org/0009-0000-7170-2200)
- Noor Gul
- Arshed Ahmed
- Zhao Zhang
- Ming Li
- Bing Liu
- Mahmoud A. Abdelhamid
Institutions
- Ain Shams University (EG)
- University of Peshawar (PK)
- Inner Mongolia Academy of Agricultural & Animal Husbandry Sciences (CN)
- Xinjiang Academy of Agricultural Sciences (CN)
- Sanya University (CN)
- China Agricultural University (CN)
Publication Details
- Journal
- Computers and Electronics in Agriculture
- Published
- 2026-09-21
- DOI
- https://doi.org/10.1016/j.compag.2026.112443
- Primary Topic
- Smart Agriculture and AI
- Type
- article
- Field-Weighted Citation Impact
- 0.00