CropGuardNet: A Unified Lightweight CNN-Transformer Framework with Multi-Scale Attention and Explainable AI for Cross-Crop Leaf Disease Detection

1School of Engineering and Science, Indian Institute of Technology Madras Zanzibar, Tanzania
2Wadhwani School of Data Science and AI, Indian Institute of Technology Madras, Chennai, India
Manuscript Under Peer Review (2026)

Plant leaf disease detectors built for precision scouting are typically either restricted to single crops, inflated by near-duplicate augmented images, or too large to run offline on smallholder smartphones. CropGuardNet integrates a scaled MobileNetV3-Small backbone with a three-branch dilated multi-scale feature pyramid, depthwise separable refinement, squeeze-and-excitation attention, a two-head Transformer, and host-species conditioning within 481,574 parameters (1.84 MB FP32, 63.8M FLOPs). To eliminate data leakage before evaluation, we purge 80,238 offline-augmented copies from PlantVillage using specimen UUID grouping and 64-bit perceptual hash checks, leaving 35,420 unique images across eight crops and 38 classes. Under this deduplicated benchmark, CropGuardNet runs in 5.00 ms per leaf image on single-thread CPU ONNX Runtime, sustains 99.17% test accuracy (0.9874 F1-macro), eliminates cross-crop false positives, and explains decisions across four attribution methods.

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

This side-by-side diagnostic matrix inspects visual explanations produced by four attribution methods (Grad-CAM++, LayerCAM, LIME, and GradientSHAP) across all eight host crops under guided Mode A1 inference. Gradient-based saliency focuses tightly on necrotic leaf spots and fungal halos instead of soil backgrounds, matching strong Deletion faithfulness (0.7262 LayerCAM AUC) and Insertion recovery (0.9259 GradientSHAP AUC).

Classification Accuracy Under 20 Image Corruptions

Each panel traces classification accuracy across five progressive severity levels under Gaussian sensor noise, motion blur, extreme under/overexposure, central occlusion, and aggressive JPEG compression. Across 20 held-out corruption regimes, CropGuardNet retains the highest mean accuracy (83.61%) and avoids the steep brightness-drop and occlusion failures observed in smaller edge baselines (Wilcoxon p = 0.0020 versus LeafXNet at severe noise/brightness).

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%.

These three panels evaluate real-world generalization to uncurated PlantDoc smartphone field images across zero-shot transfer, frozen-backbone few-shot adaptation, and full fine-tuning. Supplying known host crop species (Mode A1) eliminates cross-crop confusion and lifts zero-shot accuracy from 17.58% to 40.63%-45.91%, and unenhanced raw RGB fine-tuning reaches 63.66% accuracy because clean-background CLAHE enhancements degrade cluttered field photographs.

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.

ModelParamsSize (MB)FLOPs (M)Acc (%)F1-MacroMCCLatency (ms)
VGG-16134,416,230512.7630,932.697.950.97030.9787414.72 ± 17.82
ResNet-5023,585,89489.978,174.499.130.97510.991078.03 ± 2.38
MangoXNet4,426,37416.89273.899.150.97460.991216.36 ± 0.75
EfficientNet-B04,056,22615.47769.299.210.98340.991830.79 ± 1.78
MobileNetV3-Small1,556,8065.94111.199.230.97400.992011.38 ± 0.53
LeafXNet79,7820.301,156.697.270.95580.971722.64 ± 0.55
CropGuardNet (Ours)481,5741.8463.899.170.98740.991411.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/}
}