SAAIL Lab SAAIL Lab
Under Peer Review · 2026 Under Peer Review

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 (WSDSAI), Indian Institute of Technology Madras, Chennai, India
Manuscript Under Peer Review (2026)
CropGuardNet: A Unified Lightweight CNN-Transformer Framework with Multi-Scale Attention and Explainable AI for Cross-Crop Leaf Disease Detection

Summary: CropGuardNet integrates CLAHE-Gaussian-high-pass preprocessing, MobileNetV3-Small (alpha = 0.50), a 3-branch dilated Multi-Scale Feature Pyramid (r in {1, 2, 4}), depthwise separable refinement, SE attention, a 1-layer 2-head Compact ViT (10,176 params), dual-path pooling, and crop-aware conditioning in 481,574 parameters (1.84 MB FP32, 63.8M FLOPs, 5.00 ms CPU ONNX).

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 (alpha = 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.

Keywords: plant disease detectionlightweight CNNVision Transformerexplainable AImulti-crop classificationdata deduplicationsmart agriculture

Key Findings & Contributions

481,574
Parameters
1.84 MB FP32 · 63.8M FLOPs
5.00 ms
CPU ONNX Latency
200.0 FPS single-thread
99.17%
Test Accuracy
0.9874 F1-macro · n = 5,314
80,238
Duplicates Purged
UUID + 64-bit pHash audit
83.61%
20-Corruption Mean
+18.28 pp vs. LeafXNet
99.79%
Auto Crop Routing
Zero cross-crop FP (Mc = 0)
  1. Designed a compact 481,574-parameter hybrid CNN-Transformer combining parallel dilated multi-scale convolutions (r in {1, 2, 4}), depthwise separable refinement, squeeze-and-excitation recalibration, and dual-path GAP fusion at 63.8M FLOPs.
  2. Introduced a learnable 8-species crop-aware conditioning module eliminating cross-crop false positives under guided inference and supporting two-stage automatic crop routing (Mode A1-Auto) at 99.79% species accuracy.
  3. Constructed a leak-free multi-crop benchmark of 35,420 unique leaf images across 38 classes and 8 crops by purging 80,238 offline-augmented PlantVillage duplicate copies via specimen UUID grouping and auditing cross-split similarity via 64-bit DCT perceptual hashing.
  4. Evaluated four complementary XAI families (Grad-CAM++, LayerCAM, LIME, GradientSHAP) through 20-step Deletion/Insertion faithfulness curves alongside 20-regime corruption stress tests, 8-fold leave-one-crop-out probing, and external PlantDoc field adaptation.

Key Empirical Figure

Pareto efficiency across trainable parameters, FLOPs, and PyTorch vs. single-thread CPU ONNX latency (5.00 ms / 200.0 FPS).
Pareto efficiency across trainable parameters, FLOPs, and PyTorch vs. single-thread CPU ONNX latency (5.00 ms / 200.0 FPS).

Benchmark Results

Unified 8-Crop, 38-Class Benchmark Comparison (Test n = 5,314)

CropGuardNet ranks first in 38-class F1-Macro, Macro-Precision, and Macro-Recall while achieving the lowest FLOPs across all seven architectures.

ModelParamsSize (MB)FLOPs (M)Acc (%)F1-MacroMCCCPU Lat. (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 (PyTorch) / 5.00 (ONNX)

Layer-by-Layer Architecture & Trainable Parameter Breakdown

Total trainable parameters: 481,574 (1.84 MB FP32, 0.92 MB FP16, 0.46 MB raw INT8).

Stage / ModuleConfigurationOutput ShapeParamsShare (%)
1. BackboneMobileNetV3-Small (α = 0.50, features-only, stride 32)B × 288 × 7 × 7272,28856.54
2. MSFP Pyramid3 parallel branches (1×1; 3×3 r=2; 3×3 r=4) + 1×1 fuseB × 32 × 7 × 7178,43237.05
3. DSR RefinementDWConv 3×3 (288) + PWConv 1×1 (1,024) + BN + SiLUB × 32 × 7 × 71,3760.29
4. SE AttentionGAP + bias-free FC 32→8→32 + SigmoidB × 32 × 7 × 75120.11
5. Compact ViTPosEmbed (1,568) + 2-head MHSA (4,224) + FFN + 3×LNB × 32 × 7 × 710,1762.11
6. Dual-Path FusionGAP(F_SE) || GAP(F_Trans) parameter-free poolingB × 6400.00
7. Crop ConditioningEmbed(8×16) + Linear 80→64 + SiLU + Drop(0.1)B × 645,3121.10
8. Classifier HeadLinear 64→128 + SiLU + BN + Drop(0.3) + Linear 128→38B × 3813,4782.80
TotalComplete CropGuardNet (1.84 MB FP32)B × 38481,574100.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/}
}
APA Citation

Nyalala, I. (2026). CropGuardNet: A Unified Lightweight CNN-Transformer Framework with Multi-Scale Attention and Explainable AI for Cross-Crop Leaf Disease Detection. Manuscript Under Peer Review. https://saaillab.github.io/papers/cropguardnet/