Abstract:
AbstractObjective Accurate identification of diverse tomato leaf diseases is often hindered in practical agricultural applications by two coupled problems: substantial visual variation among disease categories leads to imbalanced recognition difficulty, and deep-learning-based detectors frequently produce confidence scores that deviate from the actual empirical accuracy, undermining the trustworthiness of automated decisions. To address these problems jointly, this study improves the Faster R-CNN framework by introducing a class-specific focal loss (CSFL) and a dual-parameter calibration (DPC) strategy, aiming to enhance detection accuracy for multiple tomato diseases while simultaneously improving the reliability of the model's confidence outputs.
Methods Considering the characteristics of leaf-level bounding-box detection tasks, differentiated scaling factor α and focusing parameter γ were preset for each disease category according to its visual feature complexity and sample scarcity, in order to construct the CSFL function. Instead of applying a single uniform loss across all categories, this category-specific parameter configuration reweights the training gradients according to category-specific recognition difficulty and thereby alleviates the imbalance in identification difficulty among categories with markedly different lesion morphologies. For confidence calibration, the idea of vector scaling was adopted to jointly optimize a class-specific temperature parameter and bias parameter within the logit transformation layer, realizing the proposed DPC mechanism as a post-hoc calibration step without altering the bounding-box coordinates or degrading detection precision.The expected calibration error (ECE) was introduced as the core evaluation metric to quantify the discrepancy between predicted confidence and empirical accuracy, and the maximum calibration error (MCE) was additionally reported to capture worst-case miscalibration. The proposed framework was trained and tested on a dataset covering six major tomato diseases, namely early blight, late blight, leaf mold, powdery mildew, septoria leaf spot, and tomato mosaic virus, and was further validated on an independent field dataset collected under real agricultural conditions with complex backgrounds, occluded leaves, and uncontrolled illumination, so as to examine the model's generalization capability beyond the controlled training environment.
Results The improved model achieved a mean average precision (mAP0.5) of 96.07%, showing a clear advantage in detection accuracy over mainstream detectors such as RT-DETR (92.31%) and RetinaNet (75.01%). Meanwhile, the model maintained a real-time detection speed with a frame rate of 80.21 FPS, outperforming the baseline Faster R-CNN (79.20 FPS). Compared with YOLOv8s, the proposed model's mAP0.5 was slightly lower than YOLOv8s's 98.69%, but its calibration reliability was markedly superior: the ECE decreased from 4.49% of the baseline Faster R-CNN to 2.96% after DPC was applied, notably lower than YOLOv8s's 5.41% and RT-DETR's 4.82%, while the MCE was 27.07%, far below YOLOv8s's 42.96% and RetinaNet's 46.99%. These results indicate that the proposed calibration mechanism effectively alleviates the overconfidence problem that is commonly observed in deep-learning-based agricultural disease detection models. Under the more challenging field test set, characterized by natural background interference and uncontrolled lighting, the model still maintained an mAP0.5 of 90.23% while keeping the ECE stable at a relatively low level of 8.02%, demonstrating consistent detection accuracy and calibration robustness beyond the controlled training environment.
Conclusions The proposed model achieves a favorable balance between detection precision and confidence reliability in tomato leaf-level disease detection, confirming its decision-making robustness and practical deployment potential under complex and open field environments. These findings provide a valuable reference for optimizing the reliability of deep-learning-based models applied to agricultural disease detection, and lay a foundation for extending this calibration-aware detection paradigm to a broader range of crop protection applications.