Abstract:Aiming to improve the detection accuracy of small apple inflorescences during the chemical thinning period in complex orchard environments and enhance overall detection performance, an improved YOLO v7-tiny based model named EMA and Slim-neck and WIoU-YOLO (ESW-YOLO) was proposed. The backbone network, neck network, and loss function of YOLO v7-tiny were modified. An efficient multi-scale attention (EMA) module was introduced to replace some convolutional layers in the backbone, enabling the model to focus more effectively on inflorescences while ignoring complex backgrounds. The GSConv-Slim-neck paradigm was incorporated into the neck network, reducing computational costs without compromising accuracy. Additionally, a dynamic non-monotonic focusing mechanism, wise intersection of union (WIoU), was adopted to address challenges in detecting small, overlapping, and occluded objects, thereby improving detection precision. Experimental results demonstrated that the proposed model achieved precision (P) of 83.02%, recall(R) of 82.04%, and mean average precision (mAP) of 86.83%, representing increases of 2.62, 3.74, and 3.43 percentage points respectively compared with that of the YOLO v7-tiny model, while reducing the number of parameters by 5.48%. ESW-YOLO outperformed YOLO v5s, YOLO v7-tiny, and YOLO v8s in all metrics. Furthermore, in detection tasks under different lighting conditions (front light, back light) and for different apple varieties (Red fuji, Ruixue, Ruixianghong), ESW-YOLO consistently achieved F1 scores higher than YOLO v7-tiny, with all detection examples scoring above 84%. The Score-CAM method was used to visualize the heatmaps of the output layers in the model’s backbone and neck networks, enhancing the interpretability of the model.