# A Real-Time Fabric Defect Detection Method Based on Improved YOLOv8
## 1 Introduction  
Fabric defect detection is a critical task in textile manufacturing, as defects can significantly impact both product quality and production efficiency. These defects, including cracks, color variations, and holes, are often caused by factors such as raw material quality, manufacturing processes, and equipment [1]. Moreover, defects not only affect the aesthetic value of the products but also pose potential risks to fabric durability and safety [2]. Therefore, accurate and effective defect detection during the production process is crucial to maintaining product quality and controlling costs.  
However, fabric defect detection faces many challenges. Fabric defects typically exhibit complex characteristics, such as large size variations, numerous small defects, and complex background textures, making detection accuracy a significant challenge [3]. Real-time, accurate fabric defect detection is filled with technical challenges [4]. Traditional manual inspection and machine vision-based methods are often limited by subjectivity, reliance on human expertise, and handcrafted feature extraction, making it difficult to adapt them to the varied characteristics and detection needs of fabric defects [5]. In recent years, deep learning has demonstrated high accuracy and real-time capabilities in defect detection, particularly convolutional neural network-based models like YOLO. These models have become the dominant approach due to their efficiency and speed [6].  
Although the YOLO model has excellent detection performance, it still suffers from the problems of large computational volume, poor detail reproduction, and limited generalization ability in the detection of fabric defects in high-resolution images. For this reason, this paper proposes an improved model based on YOLOv8, which makes the following three innovative improvements for these problems:  
1. For the problem of the large computational volume of the traditional Bottleneck residual block, the lightweight RG-C2f module is designed to effectively improve the inference speed and meet the demand for real-time detection of high-resolution images.  
2. To solve the problem of insufficient recovery of edge details in the upsampling method, introduce the DySample upsampling operator to improve the recovery of edge details in the upsampling process and enhance the localization accuracy of defect edges.  
3. To solve the problem of insufficient adaptability of the CIoU loss function to sample quality differences, the adaptive inner-WiU loss function is designed to dynamically adjust the penalties for different sample qualities to enhance the robustness and generalization ability of the model.  
Experimental results show that the YOLOv8 model proposed in this paper achieves significant improvement in both accuracy and efficiency, demonstrating its application potential and technical advantages in fabric defect detection tasks.  
The rest of the paper is organized as follows: Section 2 describes the related work; Section 3 details the improved model proposed in this paper, including the network architecture and key technologies; Section 4 describes the experimental design, covering the dataset, experimental environment, evaluation metrics, ablation experiments, and comparative experiments; and Section 5 summarizes the full paper and looks forward to future research directions.