For the detection of laser welding defects of new energy vehicles, the traditional detection methods are inefficient and have limited accuracy. The existing visual detection methods mainly use area array cameras and image processing algorithms for detection. The image acquisition efficiency of the area array camera is low. The traditional image processing methods are vulnerable to the strong reflection on the surface of new energy vehicles, and the recognition speed and accuracy are limited. Therefore, in this paper, the linear array high-resolution camera is used for two-dimensional image acquisition, and the deep learning method is used for the recognition of weld defects. Based on the single-stage target detection network, the YOLO network is optimized according to the particularity of weld defects. The weld data set and defect data set are prepared, and the data set is used to train the optimized YOLO model. The feasibility of the method is verified by experiments, which can meet the mainstream weld length detection standards in the automotive industry.