Aiming at the problems such as small target scale, complex background, difficult detection, false detection and leakage detection of aerial insulators in transmission lines, this paper proposes an insulator defect detection algorithm based on improved YOLOv5. Firstly, CBAM attention module is added to the backbone network of YOLOv5 to improve the feature extraction capability of insulator pictures. Secondly, in the feature extraction part, PANet structure is replaced by BiFPN structure to make full use of the underlying feature information. Finally, the improved K-means algorithm is used to determine the prior frame and improve the defect detection accuracy of the insulator. Experimental results show that this method can improve the identification accuracy of insulator defect detection in transmission lines.