# Fabric Defect Detection Method Using SA-Pix2 pix Network and Transfer Learning
## 1 Introduction
Subsequently, image segmentation is performed on the reconstructed image in comparison with the original fabric image to obtain a defect map containing defect information. This image reconstruction algorithm only requires training with normal and defect samples, eliminating the need to label defect samples and thus reducing the manual effort involved in annotating defects. Within image segmentation methods, autoencoder networks [18] or generative adversarial networks [19] are commonly employed for the pixel-level segmentation of fabric defect images. Autoencoders are typically trained in an unsupervised manner, using defect-free samples, avoiding the necessity to collect a large number of defect samples for network training. [PERSON] et al. [20] introduced the CU-Net model, which incorporates attention mechanisms into the classical U-Net architecture and employs a novel composite loss function for training. They evaluated the model using the publicly available AITEX fabric defect dataset, demonstrating an enhancement in fabric defect detection accuracy. Meanwhile, [PERSON] et al. [21] proposed an unsupervised defect detection algorithm based on a reconstruction network (ReNet-D). This approach involves dividing images into equally sized patches for training, enabling defect detection in texture images of varying complexities. Although autoencoder-based defect detection methods require only normal samples during network training, they can only learn the features of normal samples. During defect reconstruction, since defects may resemble the texture background of the original image, it can lead to the retention of excessive defect features in the reconstructed image, thereby reducing detection accuracy. Furthermore, autoencoderslose a significant amount of image information during training and cannot reconstruct clear images, making it challenging to apply this method to the detection of complex pattern fabric defects. Since the inception of Generative Adversarial Networks (GANs), their application has been extensive across diverse domains including steel [22], photoplates [23], and medicine [24] for image defect detection. [PERSON] et al. [25] introduced a GAN-based framework specifically tailored for fabric defect detection. This framework commences by training a GAN to explore the conditional distribution of defects across varied texture backgrounds, utilizing a multilevel GAN structure to synthesize imperceptible defects within defect-free fabric samples. Subsequently, the synthesized defects are integrated into specific locations within new fabric instances. The final stage involves training a deep semantic segmentation network tasked with detecting defects within the generated defect images. [PERSON] et al. [26] proposed a framework for generating adversarial networks based on attentional feature fusion for unsupervised detection of defects in dyed fabrics, which enhances the model's attention to texture details through multilevel information fusion and attentional mechanisms to improve the detection of defects in yarn-dyed fabrics. The utilization of GAN networks presents augmented image feature extraction capabilities due to their inherent architecture. Moreover, their competitive adversarial-based training mechanism proves particularly adept in processing intricate patterned images [27], effectively diminishing the requisite number of training samples [28]. In contrast to self-encoders, GANs exhibit greater suitability in processing fabric images characterized by complex textures. The intricate nature of fabric production, characterized by a diversity of species, small batch sizes, and high product yields, poses a significant challenge in acquiring ample sample data. This scarcity severely constrains the accuracy of detection model training. Introducing migration learning [29; 30], a technique that migrates feature extraction capabilities to a designated network by weight sharing within the network model, stands as a promising solution.