Abstract:Aiming at the difficulty of manual identification of O-ring defects, an automatic detection method of surface defects based on the improved YOLOv5 was proposed. In the data preprocessing stage, the semi-automatic labeling method was used to reduce the cost of manual labeling, and the number of mosaic images used was changed to nine to realize the mosaic data enhancement method. A label smoothing method was introduced in the network prediction layer to reduce the model's over-reliance on labels. The convolutional attention mechanism module was added to the backbone network to highlight the valid information, so that the backbone network could extract more detailed local feature information. At the same time, because of the characteristics of large scale changes of defect types, a pruned bidirectional feature pyramid network was introduced to tackle the loss of both large and small defects in the feature extraction process. The experimental results show that compared with the original YOLOv5, the average accuracy of O-ring surface defect detection in the improved YOLOv5 is increased by 4.26%, and the detection speed is within 25 ms, which can meet the actual production needs.