With the development of industrial economy, more and more enterprises use machine vision and artificial intelligence to replace manual detection. Therefore, the research of steel surface defect detection based on artificial intelligence is of great significance to promote the rapid development of intelligent factory and intelligent manufacturing system. In this paper, Yolov5 deep learning algorithm is used to build a classification model of steel surface defects to realize the classification and detection of steel surface defects. At the same time, on the basis of Yolov5, combined with the attention mechanism, the backbone network is improved to further improve the classification model of steel surface defects. The experiment shows that the Recall and mAP of improved Yolov5 perform better on the steel surface defect data set. Compared with Yolov5, the number of C3CA-Yolov5 parameters decreased by 13.02%, and the size of pt files decreased by 12.72%; the number of C3ECA-Yolov5 parameters decreased by 13.36%, and the size of pt files decreased by 13.22%.