# Fabric Defect Detection Based on Improved Lightweight YOLOv8n
## 3 Result and Discussion
### Dataset Description  
The experimental dataset was selected from actual scenarios captured by a textile manufacturing enterprise and the Tianchi [19] public dataset. Images captured from actual scenarios were used for training and testing; a total of 2115 images containing textile defects were used for training and testing. These images include six common textile defects: Float, Skips, Pilling, Hole, Pulling Out Yarn, and Stain. The six types of common textile defects are illustrated in Figure 5. Due to the high similarity between noise and minor defects in textile images, to improve the model's generalization ability and robustness and to prevent overfitting, this study utilized data augmentation methods such as rotation, scaling, cropping, and color changes to expand the dataset to three times its original size, resulting in a total of 6345 images. The dataset was randomly divided into training, validation, and test sets in a ratio of 8:1:1. The final training samples consisted of 1376 images of Float, 1011 images of Skips, 606 images of Pilling, 336 images of Hole, 2016 images of Pulling Out Yarn, and 1734 images of Stain, totaling 6345 images. Additionally, a portion of the Tianchi public textile image dataset was selected to validate the generalization capability of the proposed model.  
To investigate the impact of augmented data on defect detection performance, a comparative experiment was designed to evaluate the detection effectiveness before and after data augmentation. The evaluation metrics selected for this experiment were [EMAIL_ADDRESS], Recall (R), and Precision (P). The experimental results are shown in Table 1. According to the results presented in Table 2, it can be concluded that the augmented dataset demonstrates higher [EMAIL_ADDRESS], Recall, and Precision values compared to the original dataset, indicating improved overall model performance. Therefore, the subsequent comparative and ablation experiments were conducted using the augmented dataset.  
The confusion matrices in Figure 6 compare the model's performance before and after augmenting the training dataset. The left matrix, based on the original dataset, shows a higher number of false positives, particularly in the \"Stains\" and \"Background\" categories, with dispersed off-diagonal values, indicating overestimation errors caused by insufficient and imbalanced training samples [20]. After augmenting the dataset (right matrix), the off-diagonal values significantly decrease, and the Precision improves, with more concentrated diagonal values for categories like \"Stains\" and \"Background\", indicating more accurate predictions. This improvement demonstrates that data augmentation effectively reduces overestimation errors, enhancing the model's robustness and generalization capability.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model** & **Data Augmentation Status** & **R (\%)** & **P (\%)** & **[EMAIL_ADDRESS] (\%)** \\ \hline \multirow{2}{*}{YOLOv8n} & NO & 89.90 & 92.90 & 94.40 \\  & YES & 94.80 & 96.60 & 97.70 \\ \multirow{2}{*}{GSL-YOLOv8} & NO & 87.48 & 93.14 & 92.87 \\  & YES & 96.34 & 97.03 & 98.29 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Comparative experiments of different models before and after data augmentation.  
Figure 5: Fabric defect types.