CropGuardNet: A Unified Lightweight CNN-Transformer Framework with Multi-Scale Attention and Explainable AI for Cross-Crop Leaf Disease Detection
Abstract
Crop diseases threaten food security, yet deep detectors remain single-crop, heavyweight, or opaque for edge deployment. We propose CropGuardNet, a lightweight Convolutional Neural Network (CNN) and Transformer framework on MobileNetV3-Small (α = 0.50) with 481,574 parameters, 1.84 MB FP32 weights, and 63.8M FLOPs, running at 5.00 ms (200.0 FPS) in single-thread CPU ONNX inference. It unites a dilated multi-scale feature pyramid, depthwise separable refinement, squeeze-and-excitation attention, a two-head Transformer, dual-path pooling, crop-aware conditioning, and four explainable AI (XAI) methods: Grad-CAM++, LayerCAM, LIME, and GradientSHAP. After purging 80,238 PlantVillage duplicates via specimen Universally Unique Identifier (UUID) grouping and 64-bit perceptual hash auditing, evaluation on 35,420 unique images spanning 38 classes and 8 crops (n = 5,314 test) reaches 99.17% accuracy, 0.9874 F1-macro, 0.9914 Matthews correlation coefficient (MCC), and 0.9998 AUC-ROC, leading F1-macro across seven models at 3.2x-279.1x fewer parameters than five baselines and 6.0x larger than LeafXNet at 18.1x fewer FLOPs. Top models match on 35 non-Rice classes, whereas species conditioning eliminates cross-crop errors, supports 99.79% automatic crop routing, and lifts minority Rice accuracy to 94.44%. CropGuardNet leads 20-regime corruptions at 83.61% mean accuracy (severe Wilcoxon p = 0.0020 vs. LeafXNet), 8-fold leave-one-crop-out probing (n = 7,072) at 81.22% accuracy and 0.8879 binary AUC-ROC, and XAI faithfulness with LayerCAM Deletion AUC 0.7262 and GradientSHAP Insertion AUC 0.9259. On PlantDoc field images, guided Mode A1 reaches 40.63%-45.91% zero-shot accuracy vs. 16.06%-17.58% unguided, 60.62% unmasked vs. 62.18% masked head adaptation under Mode A1-Auto (tying ResNet-50 behind LeafXNet at 63.73%), and 62.20% Enhanced or 63.66% Raw RGB accuracy after 20-epoch tuning.
Cross-Crop Explainability & Attribution Faithfulness
Classification Accuracy Under 20 Image Corruptions
Results
Across seven benchmarked architectures on the 5,314-image deduplicated test split, CropGuardNet ranks first in 38-class F1-macro (0.9874), using 3.2x to 279.1x fewer parameters than five heavier baselines and 18.1x fewer FLOPs than LeafXNet. Host-species conditioning eliminates cross-crop errors completely (Mc = 0), supports two-stage automatic crop routing at 99.79% species accuracy, and lifts minority Rice discrimination to 94.44%. On 20 held-out image corruptions, CropGuardNet retains the highest mean accuracy at 83.61% (Wilcoxon p = 0.0020 versus LeafXNet at severe noise and brightness shift), and on uncurated PlantDoc smartphone field images, guided Mode A1 lifts zero-shot accuracy from 17.58% to 40.63%-45.91% before raw RGB fine-tuning reaches 63.66%.
Unified 8-Crop, 38-Class Benchmark Comparison (Test n = 5,314)
CropGuardNet ranks first in 38-class F1-Macro and achieves the lowest FLOPs across all seven architectures. *11.49 ms PyTorch / 5.00 ms ONNX Runtime CPU latency.
| Model | Params | Size (MB) | FLOPs (M) | Acc (%) | F1-Macro | MCC | Latency (ms) |
|---|---|---|---|---|---|---|---|
| VGG-16 | 134,416,230 | 512.76 | 30,932.6 | 97.95 | 0.9703 | 0.9787 | 414.72 ± 17.82 |
| ResNet-50 | 23,585,894 | 89.97 | 8,174.4 | 99.13 | 0.9751 | 0.9910 | 78.03 ± 2.38 |
| MangoXNet | 4,426,374 | 16.89 | 273.8 | 99.15 | 0.9746 | 0.9912 | 16.36 ± 0.75 |
| EfficientNet-B0 | 4,056,226 | 15.47 | 769.2 | 99.21 | 0.9834 | 0.9918 | 30.79 ± 1.78 |
| MobileNetV3-Small | 1,556,806 | 5.94 | 111.1 | 99.23 | 0.9740 | 0.9920 | 11.38 ± 0.53 |
| LeafXNet | 79,782 | 0.30 | 1,156.6 | 97.27 | 0.9558 | 0.9717 | 22.64 ± 0.55 |
| CropGuardNet (Ours) | 481,574 | 1.84 | 63.8 | 99.17 | 0.9874 | 0.9914 | 11.49 / 5.00* |
BibTeX
@misc{nyalala2026cropguardnet,
title={CropGuardNet: A Unified Lightweight CNN-Transformer Framework with Multi-Scale Attention and Explainable AI for Cross-Crop Leaf Disease Detection},
author={Nyalala, Innocent},
howpublished={Manuscript Under Peer Review (SAAIL Lab)},
year={2026},
url={https://saaillab.github.io/papers/cropguardnet/}
} TY - UNPB TI - CropGuardNet: A Unified Lightweight CNN-Transformer Framework with Multi-Scale Attention and Explainable AI for Cross-Crop Leaf Disease Detection AU - Nyalala, Innocent PY - 2026 T2 - Manuscript Under Peer Review UR - https://saaillab.github.io/papers/cropguardnet/ KW - plant disease detection KW - lightweight CNN KW - Vision Transformer KW - explainable AI KW - multi-crop classification KW - data deduplication KW - smart agriculture AB - Crop diseases threaten food security, yet deep detectors remain single-crop, heavyweight, or opaque for edge deployment. We propose CropGuardNet, a lightweight Convolutional Neural Network (CNN) and Transformer framework on MobileNetV3-Small (α = 0.50) with 481,574 parameters, 1.84 MB FP32 weights, and 63.8M FLOPs, running at 5.00 ms (200.0 FPS) in single-thread CPU ONNX inference. It unites a dilated multi-scale feature pyramid, depthwise separable refinement, squeeze-and-excitation attention, a two-head Transformer, dual-path pooling, crop-aware conditioning, and four explainable AI (XAI) methods: Grad-CAM++, LayerCAM, LIME, and GradientSHAP. After purging 80,238 PlantVillage duplicates via specimen Universally Unique Identifier (UUID) grouping and 64-bit perceptual hash auditing, evaluation on 35,420 unique images spanning 38 classes and 8 crops (n = 5,314 test) reaches 99.17% accuracy, 0.9874 F1-macro, 0.9914 Matthews correlation coefficient (MCC), and 0.9998 AUC-ROC, leading F1-macro across seven models at 3.2x-279.1x fewer parameters than five baselines and 6.0x larger than LeafXNet at 18.1x fewer FLOPs. Top models match on 35 non-Rice classes, whereas species conditioning eliminates cross-crop errors, supports 99.79% automatic crop routing, and lifts minority Rice accuracy to 94.44%. CropGuardNet leads 20-regime corruptions at 83.61% mean accuracy (severe Wilcoxon p = 0.0020 vs. LeafXNet), 8-fold leave-one-crop-out probing (n = 7,072) at 81.22% accuracy and 0.8879 binary AUC-ROC, and XAI faithfulness with LayerCAM Deletion AUC 0.7262 and GradientSHAP Insertion AUC 0.9259. On PlantDoc field images, guided Mode A1 reaches 40.63%-45.91% zero-shot accuracy vs. 16.06%-17.58% unguided, 60.62% unmasked vs. 62.18% masked head adaptation under Mode A1-Auto (tying ResNet-50 behind LeafXNet at 63.73%), and 62.20% Enhanced or 63.66% Raw RGB accuracy after 20-epoch tuning. ER -