In order to reduce the manual workload and reduce the maintenance cost, it is particularly important to realize automatic detection of cracks. Aiming at the problems of poor real‐time performance and low precision of traditional pavement crack detection, a crack detection method based on improved YOLOv5 one‐step target detection algorithm of convolutional neural network is proposed by using the advantages of depth learning network in target detection. The images were manually marked with LabelImg annotation software, and then the network model parameters were obtained through improving the YOLOv5 network training. Finally, the cracks are verified and detected by the established model. In addition, the precision and speed of crack detection using YOLOv3, YOLOv5s, and YOLOv5s‐attention models are compared by using Precision, Recall, and F1. After comparison, it is found that the detection precision of YOLOv5s‐attention is improved by 1.0%, F1 by 0.9%, and mAP@.5 by 1.8%.