The invention provides an X-
ray weld defect detection method based on improved YOLOv8, aiming at the problems of low detection speed, missing detection,
false detection, low detection precision and the like in the existing X-
ray weld defect detection. Firstly, EMA attention is improved, a multi-scale
pooling module is added into EMA, the detection capacity of a model for weld defects of different scales is improved, and the improved EMA is added to a
backbone network of the model; secondly, a SimSPPFAvg module is provided, extraction of edge information is enhanced, and the defect positioning precision is improved; then, DualConv is introduced to replace traditional
convolution, a C2f module of the neck is improved into light-weight C2fDual, and the parameter quantity and the calculation quantity of the model are reduced; and finally, replacing the CIoU bounding box
loss function with a WIoU bounding box
loss function, and improving the generalization ability of the model to low-quality weld data. Compared with an original YOLOv8 model, the finally improved model has the advantages that the detection precision is remarkably improved, the parameter quantity and the total
floating point calculation quantity are reduced, the parameter quantity of the model is reduced while the precision is improved, and the real-time requirement of x-
ray weld defect detection in the actual industry can be met.