The DenseNet121 model was evaluated using both a frozen feature extractor and a fine-tuned (unfrozen) configuration to assess the impact of domain-specific learning (Fig 3). In the frozen setting, the model showed consistent improvement across training epochs. Initially, the model achieved a training accuracy of 40.18% and a validation accuracy of 40.53% in epoch 1. By epoch 10, training accuracy increased to 69.72%, while validation accuracy reached 68.72%. Further improvements were observed at epoch 25, with training accuracy of 88.88% and validation accuracy of 87.67%. The best validation performance occurred around epoch 47, where accuracy peaked at 92.51%. At the final epoch (50), the model achieved a training accuracy of 94.37% and a validation accuracy of 92.29%. The training loss decreased from 1.3385 in epoch 1 to 0.3429 in epoch 50. Similarly, validation loss declined from 1.2606 to 0.3471. Despite minor fluctuations, the model maintained stable convergence. The close alignment between training and validation curves indicates good generalization with minimal overfitting. Early stopping and checkpoint callbacks further improved robustness by restoring optimal weights.
In the fine-tuned (unfrozen) configuration, the DenseNet121 model also demonstrated steady and smooth convergence (Fig 3). The model started with a training accuracy of 40.43% and a validation accuracy of 44.93% in epoch 1. By epoch 10, training accuracy increased to 77.78% and validation accuracy reached 74.45%. At epoch 25, training accuracy improved to 91.69%, while validation accuracy reached 88.11%. The best validation accuracy was observed around epoch 44, reaching 93.83%. At the final epoch (50), the model achieved a training accuracy of 95.93% and a validation accuracy of 93.83%. The training loss decreased from 1.3084 to 0.2751, while validation loss declined from 1.2400 to 0.2766 over the training period. The learning curves remained smooth, with only minor variations in later epochs. The close agreement between training and validation performance confirms stable learning and strong generalization.
A direct comparison between the two configurations shows that fine-tuning resulted in a modest improvement in performance (Table 1). The validation accuracy increased from 92.29% (frozen) to 93.83% (unfrozen), while validation loss decreased from 0.3471 to 0.2766. Although this improvement is consistent, it is relatively small. This indicates that the pre-trained DenseNet121 features were already highly effective for this agricultural classification task. The limited gain from fine-tuning suggests that the dataset contains visually distinct patterns that can be captured well without extensive parameter updates. Therefore, the frozen model serves as a strong baseline, while fine-tuning provides only marginal enhancement.
Fine-tuning provided only a negligible improvement. The frozen DenseNet121 model was therefore selected for subsequent analyses. It ensures computational efficiency and stable performance without loss of accuracy.
Fig 4 shows the confusion matrix of the DenseNet121 model’s predictions (Frozen) across four classes of cowpea leaf images. The class Bacterial wilt achieved perfect classification. All 117 test images were predicted correctly with zero misclassification. This indicates the model learned the distinct visual patterns of bacterial wilt very effectively. In the Fresh Leaf class, out of 108 samples, 98 were correctly identified. However, 9 images were wrongly predicted as Mosaic virus and 1 as Septoria leaf spot. This confusion suggests some overlap in fresh and early-infected leaf appearances. This may be due to subtle visual similarities such as mild discoloration, early-stage mosaic patterns, or uneven lighting conditions that can make healthy leaves appear slightly diseased.
For the mosaic virus class, 102 of the 116 images were classified correctly. The model misclassified 12 images as fresh leaf and 1 as septoria leaf spot. These misclassifications imply visual similarity between mosaic symptoms and normal foliage, possibly due to lighting or mild infection stages. In particular, early-stage mosaic infection often presents faint chlorotic patches that resemble natural leaf texture, making it difficult for the model to distinguish from healthy leaves. Variations in illumination, shadow and image capture conditions may further reduce contrast between diseased and healthy regions.
In the Septoria leaf spot category, 112 out of 116 samples were correctly predicted. Three images were misclassified as Bacterial wilt and one as Mosaic virus. This may indicate partial symptom resemblance in late-stage infections. Such errors may occur when lesion boundaries are unclear or when multiple symptoms overlap, reducing the distinctiveness of class-specific features. Overall, the model demonstrated high precision across all classes. The confusion matrix reveals that the majority of errors occurred between Fresh Leaf and Mosaic virus, highlighting the need for finer feature extraction in similar-looking conditions. This observation suggests that incorporating more diverse field images or applying fine-tuning of deeper layers may further improve discrimination between visually similar classes.
The classification performance of the DenseNet121 model (Frozen) was evaluated using several key metrics (Table 2). The bacterial wilt class achieved a precision of 0.9669 and a perfect recall of 1.0000, indicating that all 117 infected samples were correctly identified with minimal false positives. The resulting F1-score of 0.9832 highlights the model’s strong reliability in detecting this disease. For the fresh leaf class, the model yielded a precision of 0.8909 and a recall of 0.9074. While the accuracy was high, a few fresh samples were misclassified as diseased, leading to an F1-score of 0.8991. In the case of Mosaic virus, the model attained a precision of 0.9107 and a slightly lower recall of 0.8793. The F1-score of 0.8947 suggests good overall detection, though the model occasionally confused mosaic symptoms with other categories. The septoria leaf spot class performed exceptionally well, with a precision of 0.9825 and a recall of 0.9655. Its F1-score of 0.9739 demonstrates the model’s accuracy in identifying complex leaf spot patterns.
The overall accuracy of the model was 93.87%, with both macro and weighted averages for precision, recall and F1-score hovering around 0.938. These consistent values indicate balanced performance across all four classes. In addition to these metrics, the Matthews Correlation Coefficient (MCC) was computed as 0.9184, reflecting a strong agreement between predicted and actual labels. The Multiclass AUC-ROC (OvR) score was 0.9931, suggesting the model is highly capable of distinguishing between the various disease categories.
Fig 5 presents the ROC curves of DenseNet 121-Frozen model for the four cowpea leaf classes using a one-vs-rest approach. The ROC curve illustrates the trade-off between the true positive rate (sensitivity) and the false positive rate for each class. The area under the curve (AUC) values are extremely high for all classes, indicating excellent class separability. Specifically, Bacterial wilt achieved an AUC of 0.9998, suggesting nearly perfect classification performance. Septoria leaf spot followed closely with an AUC of 0.9982. The fresh leaf class also performed well with an AUC of 0.9914, while Mosaic virus had a slightly lower but still strong AUC of 0.9831. The dashed line represents the performance of a random classifier. The curves remaining well above this line confirm that the model outperforms random guessing significantly for all classes.
Fig 6 shows the precision-recall (PR) curves of DenseNet 121-Frozen model for the four cowpea leaf classes using a one-vs-rest (OvR) setup. These curves are useful for evaluating model performance on imbalanced datasets. Precision represents the ratio of true positives to all predicted positives. Recall measures the proportion of true positives out of all actual positives. The bacterial wilt class shows a near-perfect curve with an average precision (AP) score of 0.9994. This indicates the model almost always makes correct positive predictions for this class. The fresh leaf class has an AP of 0.9867, showing strong precision and recall despite some misclassifications. The mosaic virus class achieved an AP of 0.9856. Its curve drops slightly at higher recall, suggesting a few false positives at broader thresholds. The septoria leaf spot class yielded an AP of 0.9983, which confirms excellent detection accuracy. All four curves maintain high precision across most recall values. This demonstrates the model’s reliability in distinguishing disease symptoms, especially when classifying harder-to-separate categories like fresh leaf and mosaic virus. Overall, the PR curves confirm that the model maintains high confidence in its predictions, even under relaxed decision thresholds.
Fig 7 displays sample predictions made by the DenseNet 121-Frozen model. Each image shows a cowpea leaf alongside its true label, predicted label and the model’s confidence score. All samples are correctly classified with high confidence values above 0.99. The top row includes three Bacterial wilt samples. Each shows symptoms such as curling, yellowing, or spots. The model identified all of them accurately. Confidence values range from 0.9944 to 0.9959, indicating strong certainty in its predictions. The bottom row contains one septoria leaf spot sample and two additional bacterial wilt samples. The septoria leaf displays visible dark lesions typical of this disease. The model correctly classified it with a confidence of 0.9937. The last two samples again show signs of Bacterial wilt, including discoloration and shrivelling. These were predicted correctly with high confidence. The figure confirms that the model performs reliably on clear disease cases. High confidence values support that the model is not only accurate but also sure of its decisions. This is especially important for use in real-world disease detection tasks.
DenseNet121 and other deep learning models show different levels of performance across studies because of variations in crops, dataset size, number of classes and task complexity (Table 3). The present study achieved a test accuracy of 93.87% using a DenseNet-121 model to classify four classes of cowpea leaf conditions. Compared to prior work, this performance demonstrates strong competitiveness. For example,
Dubey et al., (2022) reported 99.00% accuracy using DenseNet-121 on a larger and more diverse 15-class crop leaf dataset, while
Girmaw and Muluneh (2024) achieved 98.33% for field pea leaves, also using DenseNet-121, but on only three classes. In contrast,
Arathi and Dulhare (2023) applied DenseNet-121 to cotton leaf disease detection, achieving 91% and
Saputra et al., (2023) reported 91.67% on rice leaf disease classification, showing that the presented model performs better than or on par with DenseNet-based models in other crops.
For cowpea-specific studies,
Choudhary et al., (2023) used DenseNet-121 to distinguish cowpea from weed leaves, achieving 88.89% test accuracy. Additionally,
Trivedi et al., (2024) used a segmentation-based LinkNet-34 model with DenseNet-121 as an encoder and achieved 97.57% validation accuracy on a mixed dataset, highlighting the potential of combining segmentation with classification. The comparison results are taken from the literature. They are based on different datasets and experimental settings. Therefore, identical training or testing splits were not used.
Overall, the presented study contributes significantly to the underexplored domain of multiclass cowpea disease detection, demonstrating promising performance with potential for deployment in real-world agricultural scenarios.