YOLOv11n-DSU: A Study on Grading and Detection of Multiple Cucumber Diseases in Complex Field Backgrounds
Abstract
1. Introduction
2. Materials and Methods
2.1. Data Acquisition
2.2. Data Augmentation and Final Dataset
2.3. Multi-Disease Severity Classification Model Based on YOLOv11n
2.3.1. DEConv Convolutional Module
2.3.2. SCSA Module
2.3.3. Unified-IoU Loss Function
- 1.
- Dynamic Scale Scaling Mechanism
- 2.
- Adaptive Weight Allocation Mechanism
- 3.
- Multidimensional Geometric Constraints Mechanism
2.4. Experimental Setup and Evaluation Metrics
3. Results and Analysis
3.1. Ablation Study
3.2. Analysis of Module Decision Mechanisms and Feature Flow
3.3. Comparative Analysis of Model Classification Performance Before and After Improvement
3.4. Comparative Experiments on Loss Functions
3.5. Comparative Experiments
3.6. Lightweight Model Deployment and Detection System
4. Conclusions
5. Discussion
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
Appendix A
| import torch |
| import numpy as np |
| class UnifiedIoULoss: |
| def __init__(self, total_epochs = 500, lambda1 = 1.0, lambda2 = 0.5, lambda3 = 0.2): |
| self.total_epochs = total_epochs |
| self.lambda1 = lambda1 |
| self.lambda2 = lambda2 |
| self.lambda3 = lambda3 |
| self.gamma = 2.0 |
| self.iou_mu = 0.5 |
| self.iou_tau = 0.4 |
| def __call__(self, pred_boxes, true_boxes, conf_scores, current_epoch): |
| N = pred_boxes.shape[0] |
| ratio = 0.75 * np.cos(np.pi * current_epoch/self.total_epochs) + 1.25 |
| alpha = torch.rand(N, 1) * (ratio - 1/ratio) + 1/ratio |
| alpha = alpha.to(pred_boxes.device) |
| pred_scaled = pred_boxes * alpha |
| true_scaled = true_boxes * alpha |
| iou = self.calculate_iou(pred_scaled, true_scaled) |
| self.update_dynamic_thresholds(iou) |
| w_dynamic = torch.abs(iou - self.iou_mu).pow(self.gamma) |
| w_dynamic = w_dynamic * (iou > self.iou_tau).float() |
| L_iou = 1.0 - iou |
| L_shape = self.shape_constraint(pred_scaled, true_scaled) |
| L_angle = self.angle_constraint(pred_scaled, true_scaled) |
| L_geometric = ( |
| self.lambda1 * L_iou + |
| self.lambda2 * L_shape + |
| self.lambda3 * L_angle |
| ) |
| L_weighted = w_dynamic * L_geometric |
| L_final = (1.0 - conf_scores) * L_weighted |
| return torch.mean(L_final) |
| def calculate_iou(self, boxes1, boxes2): |
| x1 = torch.max(boxes1[:, 0], boxes2[:, 0]) |
| y1 = torch.max(boxes1[:, 1], boxes2[:, 1]) |
| x2 = torch.min(boxes1[:, 2], boxes2[:, 2]) |
| y2 = torch.min(boxes1[:, 3], boxes2[:, 3]) |
| inter = torch.clamp(x2 - x1, min = 0) * torch.clamp(y2 - y1, min = 0) |
| area1 = (boxes1[:, 2] - boxes1[:, 0]) * (boxes1[:, 3] - boxes1[:, 1]) |
| area2 = (boxes2[:, 2] - boxes2[:, 0]) * (boxes2[:, 3] - boxes2[:, 1]) |
| union = area1 + area2 - inter + 1 × 10−7 |
| return (inter/union).unsqueeze(1) |
| def shape_constraint(self, pred_boxes, true_boxes, k = 5): |
| N = pred_boxes.shape[0] |
| device = pred_boxes.device |
| L_shape = torch.zeros(N, 1, device = device) |
| for i in range(N): |
| pred_contour = self.box_to_contour(pred_boxes[i]) |
| true_contour = self.box_to_contour(true_boxes[i]) |
| pred_fourier = torch.fft.fft(pred_contour.float())[:k] |
| true_fourier = torch.fft.fft(true_contour.float())[:k] |
| L_shape[i] = torch.mean(torch.abs(pred_fourier - true_fourier) ** 2) |
| return L_shape |
| def angle_constraint(self, pred_boxes, true_boxes): |
| pred_vec = torch.stack([ |
| pred_boxes[:, 2] - pred_boxes[:, 0], |
| pred_boxes[:, 3] - pred_boxes[:, 1] |
| ], dim = 1) |
| true_vec = torch.stack([ |
| true_boxes[:, 2] - true_boxes[:, 0], |
| true_boxes[:, 3] - true_boxes[:, 1] |
| ], dim = 1) |
| pred_vec_norm = pred_vec/(torch.norm(pred_vec, dim = 1, keepdim = True) + 1e-7) |
| true_vec_norm = true_vec/(torch.norm(true_vec, dim = 1, keepdim = True) + 1e-7) |
| cos_sim = torch.sum(pred_vec_norm * true_vec_norm, dim = 1) |
| L_angle = 1.0 - torch.abs(cos_sim) |
| return L_angle.unsqueeze(1) |
| def box_to_contour(self, box, num_points = 100): |
| x1, y1, x2, y2 = box |
| t = torch.linspace(0, 1, num_points//4) |
| top = torch.stack([x1 + (x2-x1)*t, torch.full_like(t, y1)], dim = 1) |
| right = torch.stack([torch.full_like(t, x2), y1 + (y2-y1)*t], dim = 1) |
| bottom = torch.stack([x2 - (x2-x1)*t, torch.full_like(t, y2)], dim = 1) |
| left = torch.stack([torch.full_like(t, x1), y2 - (y2-y1)*t], dim = 1) |
| return torch.cat([top, right, bottom, left], dim = 0) |
| def update_dynamic_thresholds(self, iou): |
| alpha = 0.9 |
| current_mu = torch.mean(iou).item() |
| self.iou_mu = alpha * self.iou_mu + (1-alpha) * current_mu |
| self.iou_tau = 0.8 * self.iou_mu |
| def usage_example(): |
| batch_size = 32 |
| total_epochs = 500 |
| current_epoch = 250 |
| pred_boxes = torch.randn(batch_size, 4) |
| true_boxes = torch.randn(batch_size, 4) |
| conf_scores = torch.rand(batch_size, 1) |
| loss_fn = UnifiedIoULoss(total_epochs = total_epochs) |
| loss_value = loss_fn(pred_boxes, true_boxes, conf_scores, current_epoch) |
| print(f”Unified-IoU: {loss_value.item():.4f}”) |
| if __name__ == “__main__”: |
| usage_example() |
References
- Vatter, T.; Barceló, M.; Gjakoni, P.; Segarra, G.; Trillas, M.I.; Aranjuelo, I.; Kefauver, S.C.; Araus, J.L. Comparing high-cost and lower-cost remote sensing tools for detecting pre-symptomatic downy mildew (Pseudoperonospora cubensis) infections in cucumbers. Comput. Electron. Agric. 2024, 218, 108736. [Google Scholar] [CrossRef]
- Gadhi, M.A.; Nazir, T.; Majeed, M.Z.; Jatoi, G.H.; Jie, R.; Qiu, D. In-vitro and in-vivo assessment of biological control potential of nematode symbiont Xenorhabdus nematophila against Pseudomonas syringae, the causative agent of angular leaf spot of cucumber. J. Phytopathol. 2024, 172, e13351. [Google Scholar] [CrossRef]
- Li, X.; Gao, Y.; Ahmad, N.; Bu, F.; Tian, M.; Jia, K.; Sun, W.; Li, C.; Zhao, C. Ficus carica Linn leaves extract induces cucumber resistance to Podosphaera xanthii by inhibiting conidia and regulating enzyme activity. Physiol. Mol. Plant Pathol. 2024, 133, 102339. [Google Scholar] [CrossRef]
- Dolatabadian, A.; Neik, T.X.; Danilevicz, M.F.; Upadhyaya, S.R.; Batley, J.; Edwards, D. Image-based crop disease detection using machine learning. Plant Pathol. 2025, 74, 18–38. [Google Scholar] [CrossRef]
- Wang, S.; Li, Q.; Yang, T.; Li, Z.; Bai, D.; Tang, C.; Pu, H. Lsd-yolo: Enhanced yolov8n algorithm for efficient detection of lemon surface diseases. Plants 2024, 13, 2069. [Google Scholar] [CrossRef]
- Bao, W.; Fan, T.; Hu, G.; Liang, D.; Li, H. Detection and identification of tea leaf diseases based on AX-RetinaNet. Sci. Rep. 2022, 12, 2183. [Google Scholar] [CrossRef]
- Zhang, J.H.; Kong, F.T.; Wu, J.Z.; Han, S.Q.; Zhai, Z.F. Automatic image segmentation method for cotton leaves with disease under natural environment. J. Integr. Agric. 2018, 17, 1800–1814. [Google Scholar] [CrossRef]
- Wang, Z.; Xu, X.; Zhu, L.; Bin, Y.; Wang, G.; Yang, Y.; Shen, H.T. Evidence-Based Multi-Feature Fusion for Adversarial Robustness. IEEE Trans. Pattern Anal. Mach. Intell. 2025, 47, 8923–8937. [Google Scholar] [CrossRef]
- Kashef, R. A boosted SVM classifier trained by incremental learning and decremental unlearning approach. Expert Syst. Appl. 2021, 167, 114154. [Google Scholar] [CrossRef]
- Khan, R.U.; Khan, K.; Albattah, W.; Qamar, A.M. Image-based detection of plant diseases: From classical machine learning to deep learning journey. Wirel. Commun. Mob. Comput. 2021, 2021, 5541859. [Google Scholar] [CrossRef]
- Cao, Y.; Sun, G.; Yuan, Y.; Chen, L. Small-sample cucumber disease identification based on multimodal self-supervised learning. Crop Prot. 2025, 188, 107006. [Google Scholar] [CrossRef]
- Wang, B.; Pei, W.; Xue, B.; Zhang, M. A multiobjective genetic algorithm to evolving local interpretable model-agnostic explanations for deep neural networks in image classification. IEEE Trans. Evol. Comput. 2022, 28, 903–917. [Google Scholar] [CrossRef]
- Wang, C.; Du, P.; Wu, H.; Li, J.; Zhao, C.; Zhu, H. A cucumber leaf disease severity classification method based on the fusion of DeepLabV3+ and U-Net. Comput. Electron. Agric. 2021, 189, 106373. [Google Scholar] [CrossRef]
- Tang, X.; Sun, Z.; Yang, L.; Chen, Q.; Liu, Z.; Wang, P.; Zhang, Y. YOLOv11-AIU: A lightweight detection model for the grading detection of early blight disease in tomatoes. Plant Methods 2025, 21, 118. [Google Scholar] [CrossRef] [PubMed]
- Liu, F.; Zhang, Y.; Du, C.; Ren, X.; Huang, B.; Chai, X. Design and Experimentation of a Machine Vision-Based Cucumber Quality Grader. Foods 2024, 13, 16. [Google Scholar] [CrossRef]
- Zhang, S.; Zhang, S.; Zhang, C.; Wang, X.; Shi, Y. Cucumber leaf disease identification with global pooling dilated convolutional neural network. Comput. Electron. Agric. 2019, 162, 422–430. [Google Scholar] [CrossRef]
- Anandakrishnan, J.; Sangaiah, A.K.; Son, N.K.; Kumari, S.; Arif, M.L.; Abd Rahman, M.A. UAV-Based Deep Learning with Tiny-YOLOv9 for Revolutionizing Paddy Rice Disease Detection. In Proceedings of the 2024 IEEE International Conference on Smart Internet of Things (SmartIoT), Shenzhen, China, 14–16 November 2024; pp. 16–21. [Google Scholar]
- Nguyen, D.T.; Bui, T.D.; Ngo, T.M.; Ngo, U.Q. Improving YOLO-Based Plant Disease Detection Using αSILU: A Novel Activation Function for Smart Agriculture. AgriEngineering 2025, 7, 271. [Google Scholar] [CrossRef]
- Li, S.F.; Li, K.Y.; Qiao, Y.; Zhang, L.X. Cucumber disease detection method based on visible light spectrum and improved YOLOv5 in natural scenes. Spectrosc. Spectr. Anal. 2023, 43, 2596–2600. [Google Scholar]
- Yao, H.; Wang, C.; Zhang, L.; Li, J.; Liu, B.; Liang, F. A cucumber leaf disease severity grading method in natural environment based on the fusion of TRNet and U-Net. Agronomy 2023, 14, 72. [Google Scholar] [CrossRef]
- Ozguven, M.M. Deep learning algorithms for automatic detection and classification of mildew disease in cucumber. Fresenius Env. Bull 2020, 29, 7081–7087. [Google Scholar]
- NY/T 1857.1-2010; Technical Regulations for Identification of Disease Resistance of Cucumber. Chinese Academy of Agricultural Sciences, Institute of Vegetables and Flowers: Beijing, China, 2010.
- NY/T 1857.6-2010; Technical Regulations for Identification of Disease Resistance of Cucumber. Chinese Academy of Agricultural Sciences, Institute of Vegetables and Flowers: Beijing, China, 2010.
- NY/T 1857.2-2010; Technical Regulations for Identification of Disease Resistance of Cucumber. Chinese Academy of Agricultural Sciences, Institute of Vegetables and Flowers: Beijing, China, 2010.
- Li, J.; He, X.; Chen, X.; Kong, D.; Huang, T.; Song, P. HDFA-YOLO: A real-time steel surface defect detection model based on backbone lightweight design and multi-scale feature fusion. Measurement 2025, 258, 119390. [Google Scholar] [CrossRef]
- Si, Y.; Xu, H.; Zhu, X.; Zhang, W.; Dong, Y.; Chen, Y.; Li, H. SCSA: Exploring the synergistic effects between spatial and channel attention. arXiv 2024, arXiv:2407.05128. [Google Scholar] [CrossRef]
- Zhou, Y.T.; Cao, K.Y.; Li, D.; Piao, J.C. Fine-YOLO: A Simplified X-ray Prohibited Object Detection Network Based on Feature Aggregation and Normalized Wasserstein Distance. Sensors 2024, 24, 3588. [Google Scholar] [CrossRef]
- He, L.H.; Zhou, Y.Z.; Liu, L.; Zhang, Y.Q.; Ma, J.H. Research on the directional bounding box algorithm of YOLO11 in tailings pond identification. Measurement 2025, 253, 117674. [Google Scholar] [CrossRef]










| Data Subset | Total Labels | Total Images |
|---|---|---|
| Training Set | 23,008 | 5466 |
| Validation Set | 2876 | 683 |
| Test Set | 2876 | 683 |
| Total | 28,760 | 6832 |
| Disease Category | Disease Grade | Diagnostic Characteristics | Training Set | Validation Set | Test Set | Total |
|---|---|---|---|---|---|---|
| Downy Mildew | Grade 0 | Asymptomatic | 1488 | 186 | 186 | 1860 |
| Grade 1 | Lesion area < 10% of leaf surface | 1492 | 187 | 187 | 1866 | |
| Grade 3 | Lesion area covering 10–25% of leaf surface | 1308 | 164 | 164 | 1636 | |
| Grade 5 | Lesion area covering 25–50% of leaf surface | 1370 | 171 | 171 | 1712 | |
| Grade 7 | Lesion area covering 50–75% of leaf surface | 1248 | 156 | 156 | 1560 | |
| Grade 9 | Lesion area > 75% of leaf surface | 1252 | 157 | 157 | 1566 | |
| Angular Leaf Spot | Grade 0 | Asymptomatic | 1488 | 186 | 186 | 1860 |
| Grade 1 | Necrotic spots present without expansion | 1485 | 186 | 185 | 1856 | |
| Grade 3 | Lesion area < 20% of leaf surface | 1813 | 226 | 227 | 2266 | |
| Grade 5 | Lesion area covering 20–33% of leaf surface | 1824 | 228 | 228 | 2280 | |
| Grade 7 | Lesion area covering 33–67% of leaf surface | 1610 | 201 | 201 | 2012 | |
| Grade 9 | Lesion area > 67% of leaf surface | 1426 | 178 | 178 | 1782 | |
| Powdery Mildew | Grade 0 | Asymptomatic | 1488 | 186 | 186 | 1860 |
| Grade 1 | Lesion area < 33% of leaf surface | 1490 | 186 | 186 | 1862 | |
| Grade 3 | Lesion area covering 33–67% of leaf surface | 1325 | 165 | 166 | 1656 | |
| Grade 5 | Lesion area > 67% of leaf surface | 1350 | 169 | 169 | 1688 | |
| Grade 7 | Dense powdery layer with marginal browning | 1202 | 150 | 150 | 1502 | |
| Grade 9 | Necrotic area > 67% of leaf surface with severe browning | 1325 | 166 | 165 | 1656 |
| Parameter | Value |
|---|---|
| Total Epochs | 500 |
| Batch Size | 16 |
| Input Size | 640 × 640 |
| Optimizer | SGD |
| Momentum | 0.937 |
| Initial Learning Rate | 0.01 |
| Weight Decay | 0.0005 |
| Exp. No. | DEConv | SCSA | Unified-IoU | P% | R% | mAP50% | mAP50–95% | GFLOPs | Weights |
|---|---|---|---|---|---|---|---|---|---|
| 1 | × | × | × | 81.1 | 75.7 | 85.6 | 77.4 | 6.5 | 5.7 |
| 2 | √ | × | × | 85.8 | 80.1 | 89.9 | 80.7 | 24.2 | 5.7 |
| 3 | × | √ | × | 83.5 | 73.2 | 86.1 | 78.4 | 6.3 | 5.6 |
| 4 | × | × | √ | 85.9 | 79.7 | 89.7 | 79.2 | 6.3 | 5.5 |
| 5 | √ | √ | × | 86.8 | 80.1 | 90.8 | 81.4 | 24.2 | 5.7 |
| 6 | √ | × | √ | 83.5 | 83.7 | 90.9 | 78.8 | 24.2 | 5.7 |
| 7 | × | √ | √ | 78.5 | 71.9 | 82.6 | 71.5 | 6.3 | 5.6 |
| 8 | √ | √ | √ | 87.2 | 85.7 | 93.5 | 88.3 | 5.8 | 5.5 |
| Disease Category | Disease Grade | mAP50% | mAP50–95% | ||
|---|---|---|---|---|---|
| 11n | 11n-DSU | 11n | 11n-DSU | ||
| Downy Mildew | Grade 0 | 87.9 | 93.9 | 81.9 | 91.6 |
| Grade 1 | 83.5 | 94.2 | 78.7 | 90.4 | |
| Grade 3 | 82.8 | 92.0 | 77.0 | 88.8 | |
| Grade 5 | 85.6 | 89.0 | 78.9 | 84.5 | |
| Grade 7 | 85.3 | 89.6 | 78.5 | 83.7 | |
| Grade 9 | 87.0 | 94.6 | 80.7 | 88.7 | |
| Angular Leaf Spot | Grade 0 | 87.9 | 93.9 | 81.9 | 91.6 |
| Grade 1 | 75.1 | 90.8 | 64.1 | 83.5 | |
| Grade 3 | 87.7 | 93.7 | 76.6 | 88.1 | |
| Grade 5 | 83.0 | 93.8 | 73.3 | 89.2 | |
| Grade 7 | 86.8 | 94.4 | 78.5 | 89.0 | |
| Grade 9 | 91.2 | 96.5 | 82.5 | 91.5 | |
| Powdery Mildew | Grade 0 | 87.9 | 93.9 | 81.9 | 91.6 |
| Grade 1 | 87.9 | 94.8 | 81.9 | 91.5 | |
| Grade 3 | 89.2 | 96.6 | 82.9 | 91.4 | |
| Grade 5 | 87.5 | 96.6 | 77.4 | 90.4 | |
| Grade 7 | 90.8 | 91.6 | 81.0 | 85.5 | |
| Grade 9 | 81.8 | 94.1 | 72.5 | 85.1 | |
| all | 85.6 | 93.5 | 77.4 | 88.3 | |
| Loss Function | P% | R% | mAP50/% | mAP50–95/% |
|---|---|---|---|---|
| CIoU | 86.7 | 80.1 | 90.8 | 81.4 |
| GIoU | 86.8 | 80.8 | 91.3 | 79.9 |
| DIoU | 86.1 | 81.2 | 90.9 | 79.4 |
| EIoU | 87.8 | 80.1 | 91.4 | 80.4 |
| SIoU | 84.1 | 81.5 | 90.5 | 78.9 |
| Unified-IoU | 87.2 | 85.7 | 93.5 | 88.3 |
| Model | P/% | R/% | mAP50/% | mAP50–95/% | GFLOPs | Weights |
|---|---|---|---|---|---|---|
| YOLOv5n | 71.3 | 70.6 | 77.5 | 66.9 | 5.8 | 4.7 |
| YOLOv8n | 83.7 | 77.2 | 87.8 | 77.6 | 6.8 | 5.7 |
| YOLOv11n | 81.1 | 75.7 | 85.6 | 77.4 | 6.5 | 5.7 |
| YOLOv12n | 87.9 | 86.4 | 93.4 | 81.6 | 24.2 | 5.7 |
| Vision Transformer | 79.3 | 71.1 | 82.0 | 71.4 | 4.1 | 3.8 |
| Faster R-CNN | 73.0 | 68.3 | 77.3 | 69.4 | 6.1 | 5.2 |
| YOLOv11n-DSU | 87.2 | 85.7 | 93.5 | 88.3 | 5.8 | 5.5 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Tang, X.; Wang, P.; Sun, Z.; Liu, Z.; Tang, Y.; Shi, J.; Ma, L.; Zhang, Y. YOLOv11n-DSU: A Study on Grading and Detection of Multiple Cucumber Diseases in Complex Field Backgrounds. Agriculture 2026, 16, 140. https://doi.org/10.3390/agriculture16020140
Tang X, Wang P, Sun Z, Liu Z, Tang Y, Shi J, Ma L, Zhang Y. YOLOv11n-DSU: A Study on Grading and Detection of Multiple Cucumber Diseases in Complex Field Backgrounds. Agriculture. 2026; 16(2):140. https://doi.org/10.3390/agriculture16020140
Chicago/Turabian StyleTang, Xiuying, Pei Wang, Zhongqing Sun, Zhenglin Liu, Yumei Tang, Jie Shi, Liying Ma, and Yonghua Zhang. 2026. "YOLOv11n-DSU: A Study on Grading and Detection of Multiple Cucumber Diseases in Complex Field Backgrounds" Agriculture 16, no. 2: 140. https://doi.org/10.3390/agriculture16020140
APA StyleTang, X., Wang, P., Sun, Z., Liu, Z., Tang, Y., Shi, J., Ma, L., & Zhang, Y. (2026). YOLOv11n-DSU: A Study on Grading and Detection of Multiple Cucumber Diseases in Complex Field Backgrounds. Agriculture, 16(2), 140. https://doi.org/10.3390/agriculture16020140

