Deep learning has become a powerful tool for diagnosing pests and plant diseases, although conventional convolutional neural networks (CNNs) generally suffer from limited interpretability and suboptimal focus on important image features. This study examines the integration of attention mechanisms into two prevalent CNN architectures—ResNet50 and MobileNetV2—to improve the interpretability and classification of diseases impacting date palm trees. Four attention modules—Squeeze-and-Excitation (SE), Efficient Channel Attention (ECA), Soft Attention, and the Convolutional Block Attention Module (CBAM)—were systematically integrated into ResNet50 and MobileNetV2 and assessed on the Palm Leaves dataset. Using transfer learning, the models were trained and evaluated through accuracy, F1-score, Grad-CAM visualizations, and quantitative metrics such as entropy and Attention Focus Scores. Analysis was also performed on the model’s complexity, including parameters and FLOPs. To confirm generalization, we tested the improved models on field data that was not part of the dataset used for learning. The experimental results demonstrated that the integration of attention mechanisms substantially improved both predictive accuracy and interpretability across all evaluated architectures. For MobileNetV2, the best performance and the most compact attention maps were obtained with SE and ECA (reaching 91%), while Soft Attention improved accuracy but produced broader, less concentrated activation patterns. For ResNet50, SE achieved the most focused and symptom-specific heatmaps, whereas CBAM reached the highest classification accuracy (up to 90.4%) but generated more spatially diffuse Grad-CAM activations. Overall, these findings demonstrate that attention-enhanced CNNs can provide accurate, interpretable, and robust detection of palm tree diseases and pests under real-world agricultural conditions.
Diagnosing nutrient deficiencies in date palm (Phoenix dactylifera L.) is challenging due to the high visual similarity of symptoms, such as between Magnesium and Potassium deficiency, making classic subjective methods unreliable. While automated deep learning models offer an alternative, the reliability of individual models is a key concern; a statistical evaluation over five independent runs confirmed that while a strong model like ConvNeXtTiny can establish a near-perfect performance ceiling (macro F1-score of 0.9969 ± 0.0028), weaker architectures like MobileNetV2 are highly unstable and less accurate (macro F1-score of 0.9219 ± 0.0486), posing a significant risk for reliable deployment. To mitigate this unreliability, we proposed and evaluated a Class-wise Guided Weighted Soft Voting (CG-WSV) ensemble heuristic. The empirical results establish a new, statistically robust performance benchmark, with the proposed CG-WSV ensemble achieving a high-performance macro F1-score of 0.9971 ± 0.0027. This performance matched that of Unweighted and Globally Weighted Soft Voting baselines, demonstrated a 0.33% relative improvement over Hard Voting, and represented a significant relative increase of 8.16% over the unstable MobileNetV2 model. The gains over the stronger individual models were 0.54% (vs. EfficientNetB0) and 0.02% (vs. ConvNeXtTiny), confirming its ability to match the observed performance ceiling. Critically, all soft voting ensembles, including CG-WSV, demonstrated exceptional stability by completely mitigating the high variance of the weaker model, validating it as a robust strategy for ensuring reliable diagnostic accuracy and providing a definitive statistical benchmark for this agricultural diagnostic problem.