Md Mostafizur Rahman, Md Najmul Gony, Md Shafiq Ullah, Sd Maria Khatun Shuvra, Rezaul Haque, Md. Redwan Ahmed, S. M. Masfequier, Rahman Swapno, M. Murugappan, Muhammad E. H. Chowdhury, Gomesh Nair, V. Saravanan
Early detection of maize leaf diseases is essential to prevent yield losses. Existing vision-based models face challenges in real-world environments due to data imbalance, lighting variations, and interpretability. This study presents MaizeFormerX, a lightweight Vision Transformer designed for cross-domain, explainable maize disease detection on resource-limited settings. MaizeFormerX employs multi-scale patch embeddings and a Cross-Scale Attention Fusion (CSAF) module to capture both detailed lesion textures and larger disease patterns. The CSAF output is processed through a transformer encoder stack using multi-head self-attention to model long-range dependencies. Robust preprocessing and dataset-specific augmentations were applied to improve feature extraction and address class imbalances in the Dataverse, Tanzania, and Plagues Maiz datasets. For interpretability, Grad-CAM was used for pixel-level saliency mapping in an efficient web application. When benchmarked against MobileViT, EfficientFormer, TinyViT, and Swin Transformer, MaizeFormerX achieved 97.8% accuracy on Dataverse, 97.5% on Tanzania, and 96.9% on Plagues Maiz, outperforming Swin Transformer V2 by 2–3%. Cross-domain testing yielded 88.9% accuracy when trained on Dataverse and tested on Tanzania, surpassing baseline performance by 3–6%. Class-wise analysis revealed F1 scores over 98% for Healthy and MLB classes with 6× augmentation, and over 97% for MSV. Ablation studies highlighted the significance of the cross-scale attention module for high MCC during domain shifts. This study introduces a precise, explainable, and efficient image-based method for classifying maize diseases, which could aid in more targeted crop management, reduce unnecessary agrochemical use, and promote sustainable maize production in future decision-support environments.