Abstract Aiming at the requirement of a certain enterprise for the visual inspection accuracy of the surface defects of the outer sheath of the wire rope to reach 95 %, this paper adopts the existing Faster R-CNN algorithm to detect the surface defects of the outer sheath of the wire rope, and its accuracy mAP 0.5 is 8 8.7%. In order to improve the detection accuracy, the Faster R-CNN algorithm is improved. Among them, ResNeXt-101 is obtained on the basis of ResNeXt-50. It is used as the backbone network, and the attention mechanism feature pyramid network ACFPN is introduced to extract multi-scale features to enhance the network’s defect detection ability. The defect detection accuracy mAP 0.5 is improved to 93.2% In view of the diversity and large size differences of the defects of the outer sheath of the wire rope, a new loss function is constructed for the network. At the same time, the BO algorithm is used to optimize the hyperparameters of the stochastic gradient optimizer SGD of the improved network. The final designed ResNeXt101-ACFPN-Faster R-CNN algorithm is used to detect the surface defects of the outer sheath of the wire rope, and the detection accuracy mAP 0.5 reaches 95.8%. The detection goal of the enterprise is achieved. The research results show that the network optimization method proposed in this paper has a good effect on improving the detection accuracy of the surface defects of the outer sheath of the wire rope, and also verifies the effectiveness and feasibility of the algorithm improvement.