Abstract:The surface defects of cotton fabric directly determine the quality of the fabric. To address the problems of false detection and missed detection due to the significant scale variations and weak small defects in cotton fabric defect detection tasks, YOLO-CFD, a cotton fabric defect detection network based on YOLOv8s is proposed. Firstly, in order to better adapt to the scale changes of defects, a new module named BRASPPF is designed based on the Bi-Level Routing Attention mechanism; Secondly, in order to improve the feature extraction and localization ability of weak small targets, space to depth convolution blocks replaces partial convolution, and a small target detection layer is added in the neck feature fusion stage; Finally, in order to reduce the sensitivity of IoU to position shift, the NWIoU loss function is designed as the bounding box regression loss function. The experimental results show that the YOLO-CFD network model can achieve mAP@0.5 of 87.2% on the self-made cotton defect dataset, an increase of 16.5%, and the speed can meet the real-time detection requirements of industry. In addition, in the visualization experiment, the YOLO-CFD network model demonstrated a more comprehensive multi-scale feature extraction capability, which can detect weak small defect targets such as knots, splice and stains with only 12 pixels, and more accurately focus on slender global defect features such as broken end and holes. Compared to other mainstream object detection algorithms, the proposed algorithm has higher defect detection performance and can provide effective exploration for cotton fabric defect detection.