Small-modulus worms are widely used in precision transmission mechanisms. The detection of surface defects on processed small-modulus worms mainly relies on manual inspection. However, this detection method has low detection efficiency and low accuracy. In response to this issue, this paper proposed a surface defect detection method for small-modulus worms based on deep learning. Firstly, based on the geometric features and material properties of small-modulus worms, designed a two-cameras worms image acquisition system to capture small-modulus worm images. And the captured images were annotated and classified to construct a small-modulus worms defect dataset. Secondly, the you only look once version 7 (YOLOv7) network model algorithm was studied and improved. A three-stage image preprocessing algorithm was added to the YOLOV7 model to reduce the interference in distorted areas. Next, Ghost-convolution, batch normalization, Silu activation (CBS) structures were employed to replace some of the conventional CBS structures, reducing computational complexity. And we also added a width–height balance weights and alpha structure to the efficient-IoU (EIOU) loss function. Improve the fitting performance of the model on the bounding box with large aspect ratio. Furthermore, three SimAM attention modules were added to the backbone, increasing the network’s focus on key areas. Finally, experimental validation was conducted, and the results demonstrated that the performance of our proposed method is better than other existing methods. The detection accuracy reached 95.7%, with a map@50 of 94.6%. Overall, the performance met the requirements for worm defect detection.