Abstract:To address the issues of small target size of surface defects in engine oil bottles and the poor robustness of ROI candidate boxes leading to inaccurate liquid level positioning, an improved defect detection algorithm for YOLOv5s is proposed. Firstly, K-Means++ is used to initialize the clustering centers instead of K-Means, making the generated prior boxes closer to the real shape and size of the detection targets. At the same time, deformable convolution is introduced into the backbone network to improve the flexibility of feature extraction, and the SE attention mechanism is introduced to adjust the weights of different channels in the feature maps. Additionally, BiFPN is used in the neck network instead of the original PANet to achieve adaptive feature fusion of different scale information. Experimental results show that the improved YOLOv5s algorithm achieves an mAP of 96.9%, which is 6% higher than that of the YOLOv5s algorithm, and the accuracy is increased by 4%. The experimental results verify that the improved YOLOv5s algorithm outperforms the original YOLOv5s algorithm in terms of detection accuracy, solving the problem of missing small targets and inaccurate liquid level positioning.