The presence of surface defects in wire ropes (WR) may lead to potential safety hazards and performance degradation, necessitating timely detection and repair. Hence, this paper proposes a method for detecting surface defects in WR based on the deep learning models YOLOv8s and U-Net, aiming to identify surface defects in real-time and extract defect data, thereby enhancing the efficiency of surface defect detection. Firstly, the ECA attention mechanism is incorporated into the YOLOv8 algorithm to enhance detection performance, achieving real-time localization and identification of surface defects in WR. Secondly, in order to obtain detailed defect data, the U-Net semantic segmentation algorithm is employed for morphological segmentation of defects, thereby obtaining the contour features of surface defects. Finally, in conjunction with OpenCV technology, the segmentation results of the defects are quantified to extract data, obtaining parameters such as the area and perimeter of the surface defects in the WR. Experimental results demonstrate that the improved YOLOv8-ECA model exhibits good accuracy and robustness, with the model’s mAP@0.5 reaching 84.78%, an increase of 1.13% compared to the base model, an accuracy rate of 90.70%, and an FPS of 65. The U-Net model can efficiently perform segmentation processing on surface defects of WR, with an mIOU of 83.54% and an mPA of 90.78%. This method can rapidly, accurately, and specifically detect surface defects in WR, which is of significant importance in preventing industrial production safety accidents.