# A Fabric Defect Segmentation Model Based on Improved Swin-Unet with Gabor Filter
## 1 Introduction  
The textile manufacturing industry, as a representative light industry, produces millions of tons of fabric annually. It operates on a large scale and involves a complex production process, including spinning, weaving, dyeing, printing, finishing, and clothing manufacturing. Fabric defects in this industry are mainly caused by machine failures, yarn issues, poor finishing, and excessive stretching, leading to profit losses of 45-65%. Early detection of fabric defects is crucial for minimizing losses [1]. Previously, manual visual inspection was used; however, it had drawbacks such as high labor costs, slow detection speed, and high error rates. With the advent of computer vision, automated fabric defect detection has significantly improved detection efficiency, reduced costs, and enhanced productivity in the textile industry. Since the mid-1990s, the textile industry's automation of inspection for fabric defects has been a vital research area [2]. This process aims to identify and locate fabric surface defects to cut costs, reduce time, and boost productivity. Numerous researchers andengineers have worked on developing robust and efficient algorithms over the past few decades to meet industry needs effectively. Typically, in classic machine vision methods, features must be handcrafted to adapt to specific domains. Hand engineering of features is essential to classical approaches; however, such features are not suited for different tasks, which leads to the need to manually set a large number of parameters for different textures and defects. Therefore, these traditional methods are difficult to generalize to other types of fabrics for general use. In recent years, deep learning methods have become the most common method in the field of computer vision. Compared with classical machine vision methods, deep learning methods can automatically learn features directly from low-level data, and have stronger feature representation capabilities. This completely replaces the engineering of manually designed features with automated learning processes [3], achieving the effect of adapting to different types of fabric defects. [PERSON] et al. [4] introduced depthwise separable convolution on Mobile-UNet, which can extract multi-scale features while reducing complexity cost and model size and achieving state of the art performance. One recently proposed work [5] used a GAN-based image generation mechanism to repair defective sample images in order to obtain the difference between defective samples and repaired samples before segmenting the defective area. [PERSON] et al. [6] proposed a fabric defect detection model based on Cascade R-CNN and integrated block recognition and detection box merging algorithms to achieve defect detection in high-resolution images. Currently, Swin-Unet has shown strong performance in medical image segmentation; however, when applied to fabric defect detection, it has been found that it converges more slowly than traditional convolutional neural networks (CNNs) in the early stages of training, and can easily fit a locally optimal solution. This is because the texture of the fabric is often composed of periodic patterns which can be quickly learned by convolution but are more difficult for Transformers. To address this challenge, we use Swin-Unet as the benchmark method to design a more efficient network, as it has achieved good results in both accuracy and robustness. In summary, our proposed method of fabric defect detection makes the following contributions:  
1. A Transformer-based fabric defect segmentation network is proposed to solve the local optimal fitting problem of the previous transformer model. 2. We embed traditional spectral methods into the model and use a fixed Gabor filter to eliminate the influence of complex textured backgrounds on defect segmentation. 3. We design a U-shaped architecture that is not completely symmetrical, making model training easier. Meanwhile, multi-stage result fusion is proposed for precise locating of defects. 4.