Abstract:Cucumber downy mildew is caused by Pseudoperonospora cubensis through infection, severely impacting the quality and yield of cucumbers. Therefore, early diagnosis of infection structures is crucial for disease warning and prevention. A detection model for cucumber downy mildew infection structures (sporangia, spores, hyphae, and sporogenous structures) was proposed based on an improved YOLO v7 model. By introducing the squeeze-and-excitation attention mechanism (SE), the model enhanced its ability to extract features from small objects such as spores and sporangia. Additionally, the model used the normalized Wasserstein distance (NWD) to improve bounding box regression accuracy, enabling more precise localization of small targets like spores. This approach also alleviated the sensitivity of traditional IoU methods to positional deviations in small targets, thereby reducing errors and enhancing the robustness of the model. The dynamic head (DyHead) module was incorporated into the detection head, dynamically adjusting the receptive field size to improve multi-scale feature fusion. This was particularly effective in handling small objects and complex backgrounds, significantly enhancing multi-scale object detection performance. The study also explored the impact of different DyHead stacking numbers on model performance and computational complexity. Experimental results showed that when DyHead was stacked four times, the model achieved optimal mAP@0.5 and mAP@0.5:0.95 values. The improved YOLO v7 model achieved an mAP@0.5 of 86.5%, a 3.9 percentage points improvement over the original YOLO v7. In comparison with other advanced object detection models such as YOLO v3, YOLO v5s, YOLO v8x, SSD, and Faster R-CNN, the improved YOLO v7 demonstrated superior performance in both mAP@0.5 and mAP@0.5:0.95, especially in detecting small objects and handling complex backgrounds with higher accuracy and robustness. Furthermore, based on the improved YOLO v7 model, a practical cucumber downy mildew infection structure recognition system was developed. This system featured an intuitive user interface and enabled accurate identification and quantitative analysis of infection structures, including spores, sporangia, hyphae, and sporulating structures. It provided an efficient solution for the early warning and prevention of cucumber downy mildew in agricultural production.