X-ray inspection for weld defects is very important for the welding industry, but insufficient defect samples restrict the implementation of deep learning technology in this field. This paper proposes a strategy combining supervised and unsupervised data augmentation to solve this problem. DCGAN is optimized to generate synthetic defect images of appropriate resolution to expand the number of datasets. The E-ELAN structure of YOLOV7 is optimized to improve its detection accuracy. CBAM is integrated into different network models to improve their detection performance of X-ray weld defects. The experiments show that the scheme of "Improved YOLOV7 and CBAM" has the best detection performance, and its mAP is 95.57%.