# Research on Seamless Fabric Defect Detection Based on Improved YOLOv8n
## 3 Improved YOLOv8n Seamless Fabric Detection Algorithm
### Adding the LSKA Attention Mechanism  
In order to solve the problems of complex surface shapes and diverse colors of seamless fabrics, especially in detecting small folds and defects such as color spots that are close to the fabric pattern color, the LSKA (Large Separable Kernel Attention) mechanism is introduced to enhance the model's ability to extract folds, edge details, and arc features in complex backgrounds [22]. LSKA is an attention mechanism based on large-scale separable kernels, with the core idea of achieving more efficient feature extraction by decomposing large convolution kernels while reducing computational complexity. It can effectively capture the dependency relationship between feature maps in the spatial and channel domains, thereby more accurately focusing on the target area, suppressing irrelevant background interference, and improving the sensitivity and expression ability of the model to target features. In practical implementation, LSKA introduces a highly separable kernel convolution operation, which enables the model to capture feature information on a larger scale, helping to identify small folds and weak arc edges on fabric surfaces. In addition, this mechanism can preserve richer edge and texture details, further optimizing the model's performance in the feature extraction stage. The introduction of LSKA not only improves the model's ability to recognize small targets but also enhances its generalization performance in complex backgrounds, especially in high-precision detection and low-false detection rate application scenarios. The convolution calculation process of LSKA is shown in Figure 3. Standard convolution can be decomposed into three parts: deep convolution, depth extended convolution, and point convolution. LKA decomposes a \(K\times K\) convolution into a deep convolution output with a kernel size of \((2d-1)\times(2d-1)\) to capture local spatial information. Meanwhile, deep convolution can compensate for the shortcomings of subsequent deep expansion convolutions with kernel sizes of \([K/d]\times[K/d]\) to extract global spatial information from  
Figure 2: Improved YOLOv8n Structure Diagram. the output of deep convolution and finally complete the output through \(1\times 1\) convolution. The LKA module uses larger convolution kernels and focuses more on texture extraction than shape, making it difficult to distinguish other features when dealing with complex textures. Meanwhile, due to the increase in the size of the convolution kernel, the computational complexity and memory requirements will significantly increase. The LSKA module splits the two-dimensional convolution kernels of deep convolution and depth expansion convolution in the LKA module into horizontal and vertical one-dimensional convolution kernels and concatenates the decomposed convolution kernels in sequence. Although SPPF (Spatial Pyramid Pooling-Fast) performs well in feature extraction and computational efficiency, there are still some shortcomings. Firstly, it relies on multi-scale pooling for global feature extraction, which can easily overlook detailed features, especially in small target or defect detection, where key features may be lost. In addition, pooling operations can reduce the spatial resolution of feature maps, resulting in rough feature expression and difficulty in fully preserving complex textures and edge details, thereby affecting detection precision. SPPF also lacks sufficient fine-grained feature expression ability, making it difficult to characterize the target's local structural information effectively. Meanwhile, its feature fusion capability is limited, relying solely on multi-scale pooling for global feature extraction, which cannot adaptively emphasize salient regions in the image. When combining the LSKA module with the SPPF module, the model's performance in multi-scale feature extraction can be further improved.