4.1. Implementation Details
All experiments were implemented using the PyTorch deep learning framework and executed on a desktop computer equipped with an Intel
® Core™ i5-5200U CPU, 8 GB RAM, and running Windows 10 (64-bit). No dedicated GPU was used during model training or evaluation (
Table 4).
To ensure a fair comparison among the investigated backbone networks, identical optimization settings were employed for all individual models, including ResNet50, EfficientNet-B0, DenseNet121, MobileNetV2, ViT-Base, and DeiT-Small. Specifically, all models were trained using the AdamW optimizer with an initial learning rate of , a batch size of 8, weight decay of , the ReduceLROnPlateau learning-rate scheduler (factor = 0.5, patience = 2), and early stopping with a patience of three epochs. Individual backbone networks were trained for 12 epochs, while the proposed fusion models were trained for 15 epochs.
All backbone models were initialized using ImageNet pretrained weights provided by the PyTorch torchvision library. The original classification layer of each network was replaced with a task-specific classification head corresponding to the four cotton leaf disease classes, and the entire network was fine-tuned during training.
On the CPU-only system described in
Table 4, the measured training time for the individual backbone models ranged from approximately 19 to 105 min per training run, depending on the architecture. Among the evaluated models, MobileNetV2 required the least training time (approximately 19 min), whereas ViT-Base required the longest (approximately 105 min), reflecting the higher computational requirements of the Transformer architecture. These measurements are representative of the training time observed across the evaluated backbone models.
To ensure full reproducibility, we set a fixed random seed of 42 for all experiments. The same seed was used for dataset splitting, model initialization, and bootstrap resampling. The model-selection procedure consisted of first training all individual CNN and Transformer models on the training set, evaluating them on the validation set, and selecting the best-performing CNN and Transformer based on validation accuracy. These selected backbones were then used as fixed feature extractors for all fusion models, which were trained and evaluated under identical conditions. The final best fusion model was selected based on test accuracy.
4.3. Performance Evaluation
The experimental results demonstrate the effectiveness of the proposed CNN–Transformer fusion framework for cotton leaf disease classification. For the 95% bootstrap confidence intervals reported in the results tables throughout this section, we employed the percentile bootstrap method with 500 resampling iterations. In each iteration, we randomly sampled test set predictions with replacement at the individual image level, recomputed the accuracy on the resampled set, and then constructed the confidence bounds using the 2.5th and 97.5th percentiles of the resulting bootstrap distribution.
At first, we evaluated the effectiveness of six different DL architectures, namely four CNNs and two Transformer-based neural networks. The detailed classification performance is reported in
Table 7, while the computational characteristics of the individual models are summarized in
Table 8.
Out of all the individual models, Transformer-ViT-Base showed the best results in terms of accuracy with values of for accuracy, for the macro F1 score, for MCC, and for weighted AUC. This proves the excellent representational learning capability of Transformer architectures for complex disease recognition tasks. In contrast, CNN-based models demonstrated comparatively lower performance, although DenseNet121 and EfficientNet-B0 achieved competitive results with accuracies above 90%. MobileNetV2 exhibited the lowest computational complexity, making it suitable for lightweight deployment scenarios. However, this reduction in complexity was accompanied by a moderate decrease in classification performance. Although ViT-Base achieved the best predictive performance among all individual models, it also incurred the highest computational cost and an inference time of ms.
The detailed classification performance and computational complexity analysis of the fusion models are presented in
Table 9 and
Table 10, respectively. The fusion results demonstrated substantial performance improvements over all standalone architectures, confirming that CNN and Transformer representations provide complementary discriminative information. In particular, the concatenation fusion strategy achieved the best overall performance with an accuracy of
, macro F1-score of
, MCC of
, and weighted AUC of
.
To ensure full transparency, we examined the exact classification outcomes for the best-performing Concatenation Fusion model. Out of the 171 test samples, 170 were correctly classified, and only 1 was misclassified, yielding an accuracy of 99.42%. The single error corresponded to a healthy leaf sample that was incorrectly predicted as curl_virus. This near-perfect classification performance is consistent with the bootstrapped 95% confidence interval of 98.2–100.0% reported in
Table 9 and confirms the robustness of the proposed fusion approach.
The variance-based fusion strategy also achieved highly competitive performance with an accuracy of and MCC of , demonstrating that explainability-driven feature refinement can effectively reduce redundant representations while preserving highly informative disease-related features. Similarly, the ensemble fusion strategy achieved strong classification performance with an accuracy of , suggesting that prediction-level aggregation improves robustness and generalization. In contrast, weighted fusion exhibited comparatively lower performance than feature-level fusion methods, indicating that directly combining logits may not fully exploit the complementary spatial and contextual representations learned by CNN and transformer backbones.
Although the fusion approaches significantly improved classification performance, they also introduced higher computational complexity due to the simultaneous utilization of dual backbones. All fusion models required approximately G FLOPs and more than 92M trainable parameters. Among the fusion strategies, ensemble fusion achieved the lowest inference time of ms, while the variance-based fusion model exhibited the highest inference cost because of the additional feature refinement operations. Nevertheless, the substantial improvement in predictive performance justifies the increased computational overhead, particularly for high-accuracy agricultural disease diagnosis systems.
It is important to note that for computational complexity analysis, the parameter counts and FLOPs were calculated for the final model architectures used in the experiments. For each pretrained backbone, the original ImageNet classification head was replaced with the task-specific classification layer before training. Accordingly, the reported computational statistics for the fusion models include the parameters and operations of both modified backbone networks together with the additional fusion and task-specific classification layers, where applicable. The reported counts (
Table 8 and
Table 10) therefore do not represent the original ImageNet models with their original classification heads.
Overall, the obtained results confirm that integrating CNN-based local feature extraction with Transformer-based global contextual modeling substantially improves cotton leaf disease classification performance. The proposed fusion framework consistently outperformed all standalone architectures across all evaluation metrics, while the concatenation fusion strategy achieved the best balance between discriminative capability and classification robustness. These findings demonstrate the effectiveness of hybrid CNN–Transformer learning for intelligent agricultural disease diagnosis systems.
4.4. Explainability Analysis
To investigate how different explainability techniques identify disease-relevant regions while suppressing irrelevant background information, we performed a qualitative comparison using six widely adopted XAI methods: GradCAM, GradCAM++, ScoreCAM, LayerCAM, EigenCAM, and AblationCAM. We selected representative samples from the cotton leaf disease dataset to visually examine the spatial distribution of model attention.
Figure 3 presents the explanation maps generated by the six approaches for three representative test images, all correctly classified as bacterial blight. The figure is organized with each row corresponding to a test sample, and columns displaying the original image, followed by the heatmaps from each XAI method.
There is one important observation that can be made about background suppression after performing qualitative analysis. Techniques like GradCAM, GradCAM++, ScoreCAM, LayerCAM, and AblationCAM consistently resulted in activation maps that overlapped into the background area. The presence of this noise showed that the methods do, at times, give high importance to areas that are not leaf parts, thus making their explanations for localizing the diseases inconsistent. However, the EigenCAM algorithm produces very restricted and accurate activation maps only within the leaf area. By producing zero or negligible attention outside the leaf area, EigenCAM effectively eliminates false-positive attributions from the background.
Even though these models have background leakage, GradCAM++ and ScoreCAM have sharper activations of the lesion-specific features within the leaf, but their inability to eliminate the background interference means that they are not suitable for exact mapping of the disease. The EigenCAM model is the best since it combines both plant anatomy and lesion features. This behavior suggests that EigenCAM inherently captures the model’s spatial grounding more faithfully, making it particularly suitable for plant disease detection where distinguishing the target object (the leaf) from the background is essential for trustworthy explanations.
Overall, while GradCAM++ and ScoreCAM provide strong intra-leaf localization, EigenCAM outperforms them in terms of spatial contextuality by avoiding irrelevant background activations. The quantitative metrics reported in the bottom table further substantiate these visual observations.
Furthermore, to objectively assess the localization performance of the six XAI methods, we performed a quantitative evaluation using four complementary metrics: Pointing Game, IoU, AUC, and localization accuracy. These metrics evaluate different aspects of explanation quality: Pointing Game measures whether the maximum activation falls within the ground-truth region; IoU quantifies spatial overlap between binarized explanations and disease regions; AUC assesses the overall ranking of pixel importance; and Localization Accuracy measures the coverage of ground-truth regions by the top-k% most activated pixels.
Table 11 presents the average performance of each method across all test samples. The results reveal distinct performance characteristics across methods, with EigenCAM consistently achieving the highest scores in the most critical metrics.
EigenCAM exhibits superior performance compared to other methods based on all four criteria and proves its ability to localize diseases more precisely. EigenCAM scores 0.750 in the Pointing Game criterion, meaning that in 75% of test cases, this method is able to detect the most discriminative part of the disease location area. This method significantly outperforms GradCAM and AblationCAM, scoring 0.583 and 0.500, respectively. However, EigenCAM achieves the best IoU (0.457), AUC (0.806), and Localization Accuracy (0.613), implying that the attention maps generated by it not only successfully localize the areas affected by diseases but also maintain fine-grained alignment with the ground truth.
While gradient-based algorithms like GradCAM and GradCAM++ utilize the propagation of gradients through the network which are themselves subject to problems related to noisy and vanishing gradients, EigenCAM calculates the first principal component of the activations of the target convolutional layer. In doing so, it extracts the most prominent variation in the feature space, thus successfully filtering out any background noise to concentrate only on the most discriminative features. As a result, the explanation maps produced by EigenCAM are extremely precise and contextually accurate due to their high scores.
GradCAM++ and ScoreCAM exhibit competitive performance, particularly in terms of AUC (0.742 and 0.750, respectively) and IoU (0.451 and 0.435). GradCAM++ ranks second to the highest IoU, implying that the gradient weighting method used by GradCAM++ produces attention maps with high spatial agreement with the diseased regions. ScoreCAM, where gradients are replaced by forward pass perturbation scores, performs very well in ranking pixel importance (AUC = 0.750).
LayerCAM and GradCAM fall somewhere in the middle, with GradCAM obtaining the best score of the Pointing Game (0.583) among all approaches except EigenCams, whereas IoU and localization accuracy scores (both 0.330) remain quite low for GradCAM. It indicates that while GradCAM correctly locates the correct region most of the time, its attention regions usually tend to be large and not as precisely located around the lesion boundaries.
Among all models, the AblationCAM demonstrates the worst result by showing the smallest IoU (0.322), AUC (0.638), and localization score (0.301). Such a result can be caused by the fact that AblationCAM uses iterative ablation of the feature maps and, therefore, is sensitive to the perturbation methods used.
Ranking results shown in
Table 12 represent an integrated approach that takes into account all four criteria altogether. EigenCAM becomes the clear leader with an overall score of 0.906, outperforming GradCAM++ by a wide margin (GradCAM++ achieves second place with a value of 0.707).
Interestingly, the qualitative observations align well with the quantitative findings. EigenCAM’s strict confinement of attention to leaf surfaces, as visually observed in
Figure 3, is quantitatively validated by its superior IoU and localization accuracy scores. The background leakage observed in GradCAM, GradCAM++, ScoreCAM, LayerCAM, and AblationCAM is reflected in their lower IoU values, as the spurious background activations reduce the spatial overlap with ground-truth disease regions.
These findings have significant implications for the selection of appropriate XAI techniques in agricultural AI applications. Although GradCAM-based techniques are commonly used on account of their ease and efficiency, the thorough analysis conducted by us reveals that EigenCAM is far superior in terms of reliability and accuracy. EigenCAM is well suited for practical applications where plants are often photographed within their natural environment because of its capacity to ignore background distractions while still being highly sensitive to disease-related features. The method’s inherent ability to capture the most salient feature variations through principal component analysis provides a principled approach to explainability that is less susceptible to the limitations of gradient-based or perturbation-based methods. In summary, the quantitative evaluation establishes EigenCAM as the most effective XAI method for cotton leaf disease classification, achieving superior performance across all evaluated metrics.