Aiming at the current problem of steel surface defect detection with low accuracy and slow speed, which can easily lead to misdetection and omission, an algorithm for steel surface defect detection based on improved YOLOv7 is proposed. Firstly, the GAM (Global Attention Mechanism) attention mechanism is introduced, while CNeB and C3C2 are added to improve the feature extraction ability of the model by reducing the information approximation and amplifying the global interaction representation. Secondly, the WIoU (Wise-IoU) loss function is used to improve the convergence speed at the late stage of model training. Finally, the improved YOLOv7 is compared with other models. The experimental results show that the algorithm of this paper has an average detection accuracy (mAP) of 72.9% on the NEU-DET dataset, which is 4.1% higher compared with the original YOLOv7 algorithm, and the detection time is reduced by 63.6% under the same conditions, which verifies the effectiveness and feasibility of this paper's algorithm, and it has a certain value of application in industrial applications.