# Fabric Defect Detection Based on Improved Lightweight YOLOv8n
## 1 Introduction  
During textile production, defects such as thread breaks, pilling, hole, thread floats, and stains may occur due to machinery issues or operator errors, leading to poor product quality and adversely affecting the company's production efficiency [1]. The complex texture of fabric surfaces makes traditional fabric defect detection methods, which often rely on manual visual inspection, inefficient, subjective, and prone to visual fatigue. According to [2], the accuracy of manual inspection is only around 70%, which is insufficient to meet the demands of large-scale production. Therefore, it is crucial to develop an automated, efficient, accurate, and cost-effective fabric defect detection system using computer vision and deep learning technologies. Traditional object detection algorithms rely on a combination of handcrafted features and classifiers, which require high-quality images, involve complex processing, and are highly sensitive to noise and interference, limiting their effectiveness in detecting fabric defects. In recent years, deep learning-based object detection algorithms have rapidly developed in object detection due to their strong learning capabilities and robustness to scale variations. Based on the number of detection stages, deep learning-based object detection algorithms can be divided into two-stage detection algorithms, represented by Faster R-CNN [3], and one-stage detection algorithms, represented by YOLO (You Only Look Once) [4] and SSD (Single-Shot MultiBox Detector) [5]. In research on two-stage fabric defect detection algorithms, [PERSON] et al. [6] improved the prediction boxes by using an enhanced K-means clustering method and replaced the backbone network of Faster R-CNN with an optimized ResNet50. This algorithm improved the accuracy of fabric defect detection but did not address the issue of computational complexity. Compared to two-stage detection algorithms, single-stage algorithms do not require the generation of candidate regions, offering higher real-time performance. They have unique advantages in multi-scale detection and multi-task learning, and multi-scale detection can recognize objects at different scales, thereby improving detection accuracy, making them a current research hotspot in fabric defect detection. [PERSON] et al. [7] added the Fully Convolutional Squeeze and Excitation (FCSE) module to the traditional SSD and validated it on the TILDA and Xuelang datasets, resulting in improved detection accuracy. Faced with a complex textile texture background, [PERSON] ([PERSON]) et al. [8] proposed a Convolutional Squeeze and Excitation (CSE) channel attention module and integrated it into the YOLOv5 backbone, enhancing defect detection and anti-interference capabilities. [PERSON] et al. [9] embedded a channel and spatial dual-attention mechanism (CBAM) into YOLOv5, effectively improving the feature allocation issues associated with a single-attention mechanism and enhancing model accuracy. However, the computational load of the model was not significantly reduced. [PERSON] ([PERSON], [PERSON]) et al. [10] applied the k-means algorithm for the dimensional clustering of target frames and added YOLO detection layers on feature maps of different sizes. The improved network model achieved an error detection rate of less than 5%. These methods generally suffer from high computational complexity and an imbalance between accuracy and detection speed, making them difficult to deploy on resource-constrained edge devices. With the advent of lightweight networks, various scholars have combined them with YOLO models to propose new lightweight object detection algorithms. [PERSON] et al. [11] addressed the issues of complex deep learning model construction and high network complexity by using the lightweight YOLOv5s model as a base. They integrated the Convolutional Block Attention Module (CBAM) and feature enhancement module into the backbone and neck, respectively, and modified the loss function to CIoU_Loss. [PERSON] et al.