Cloth printing and dyeing defect visual detection method and system

CN122760587APending Publication Date: 2026-09-15SHAOXING COUNTY NANYANG TEXTILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611147615.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-30
Publication Date
2026-09-15

AI Technical Summary

Technical Problem

然而,现有方法普遍存在以下不足:其一,现有基于生成对抗网络的布料瑕疵生成方法,在生成瑕疵区域时大多未充分引入织物的几何结构先验

Benefits of technology

1、通过引入布料织物的周期性几何先验,对生成瑕疵的形貌进行定向调整,使瑕疵区域沿经向或纬向自然延伸,克服了传统方法中瑕疵边界模糊、形态任意的问题,合成瑕疵在形态学上与真实缺陷高度接近,避免检测模型学习到错误的缺陷模式,提高对真实瑕疵的辨识能力;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122760587A_ABST
    Figure CN122760587A_ABST
Patent Text Reader

Abstract

The application discloses a cloth printing and dyeing defect visual detection method and system, relates to printing and dyeing defect detection, and comprises the following steps: collecting a data set and preliminary training, generating rough defects, detecting performance reward feedback, geometric texture refining, closed loop iteration optimization, final model training and detection. Through periodic geometric priori and frequency domain texture keeping constraints, the application combines a closed adaptive iteration loop to generate high-fidelity synthetic defects, and effectively improves the detection rate, positioning accuracy and robustness of a cloth detection model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the detection of defects in printing and dyeing, and more specifically, to a method and system for visually detecting defects in the printing and dyeing of fabrics. Background Technology

[0002] In the textile printing and dyeing process, various defects inevitably appear on the fabric surface, such as broken warp and weft threads, color stains, holes, and blemishes. These defects seriously affect the quality grade of the fabric; therefore, accurate and efficient defect detection is a core aspect of printing and dyeing quality control.

[0003] In recent years, deep learning-based visual detection models have demonstrated significant advantages in fabric defect detection due to their powerful feature extraction capabilities. However, these models typically rely on a large number and variety of labeled defect samples for training. In real-world industrial scenarios, obtaining realistic defect samples faces numerous challenges: on the one hand, advancements in modern dyeing and printing processes have led to a continuous decrease in defect incidence, resulting in a scarcity of real defect samples and high collection costs; on the other hand, defect types are diverse, with varying shapes and scales, making it difficult to cover all possible defect patterns within a limited sample set. Therefore, utilizing sample generation techniques to expand the training dataset has become a crucial approach to improving the performance of detection models.

[0004] Generating simulated defect images using generative adversarial networks (GANs) is one of the more advanced data augmentation techniques currently available. However, existing methods generally suffer from the following shortcomings: First, most existing fabric defect generation methods based on GANs do not adequately incorporate prior knowledge of the fabric's geometric structure when generating defect regions. Fabric is composed of warp and weft yarns interwoven according to certain rules, exhibiting significant periodic geometric texture features. Existing generation methods often randomly superimpose noise onto normal fabric images or directly generate defect regions through general image translation networks. The generated defect boundaries are blurred, and the geometric shapes are arbitrary, disrupting the original linear continuity of the fabric along the warp or weft direction, resulting in significant morphological deviations between the synthesized defects and real defects. This geometric discontinuity not only leads to significant distortion in the synthesized image but also causes the detection model to learn incorrect defect morphologies, reducing its ability to identify real defects. Second, existing generation methods generally neglect the constraint of frequency domain texture consistency in the area surrounding the defect. Fabric textures exhibit specific spectral amplitude and phase distributions in the frequency domain. When defective areas are forcibly embedded into the background, their edges often introduce high-frequency artifacts or periodic structural perturbations, causing phase disturbances in the surrounding texture. This texture discontinuity may be difficult to detect visually, but it severely affects the detection model's accurate localization of defect edges, leading to a high false detection rate and localization error. Thirdly, the existing synthetic defect image generation process is mostly independent of the downstream detection task. The generator is optimized with a fixed objective function, making it impossible to know the actual impact of the currently generated synthetic image on the detection model's performance. Even with reinforcement learning frameworks that feed the detection results back to the generator, existing methods still lack dedicated refinement mechanisms tailored to fabric characteristics, and cannot perform targeted iterative adjustments to the geometric shape and texture consistency of defects based on detection feedback. This makes it difficult to match the difficulty distribution of synthetic defects with the current weaknesses of the detection model, and the generated samples cannot effectively drive the continuous improvement of the detection model's performance. In particular, the improvement in detection capability is very limited for fine linear defects extending along the fabric texture direction and weak-contrast defects that are highly similar to the background texture. In summary, existing technologies for generating images of fabric printing and dyeing defects suffer from several problems, including difficulty in maintaining the consistency of the periodic geometric texture of the fabric, difficulty in suppressing the frequency domain structural perturbations of the defect edges, and a lack of a closed-loop feedback refinement mechanism that is closely coupled with the detection task. These problems severely restrict the realism and training effectiveness of the synthesized defect images, and consequently affect the detection rate and positioning accuracy of the final detection model on the actual production line. Summary of the Invention

[0005] In view of the shortcomings of the existing technology, the purpose of this invention is to provide a visual detection method and system for fabric printing and dyeing defects.

[0006] The above-mentioned technical objective of the present invention is achieved through the following technical solution: a visual detection method for fabric printing and dyeing defects, comprising the following steps: S1. Data Collection and Initial Training: Collect fabric sample images containing real defects and normal fabric sample images without defects to construct the initial training dataset, and perform the first stage of training on the initial generative adversarial network to obtain the initial generator. S2: Roughness defect generation: Using the initial generator, a first synthetic defect image with initial roughness defect is generated by taking a normal fabric sample image without defects and its fabric texture background information as input. S3: Detection performance reward feedback: The first synthetic defect image is input into the pre-trained defect detection model for detection testing. At least one performance evaluation index data in the detection test is collected. The performance evaluation index data includes one or more of the following: defect detection rate, false detection rate, and average detection accuracy. The performance evaluation index data is used as a reward signal and fed back to the initial generator through the policy gradient method in reinforcement learning to guide the subsequent update direction of the generator parameters. S4: Geometric Texture Refinement: After receiving the reward signal, the generator performs the following two sub-steps: S41: Periodic geometric prior adjustment: Based on the periodic geometric prior constraints of the fabric, the geometric shape of the defect area in the first synthetic defect image is adjusted to maintain the linear continuity of the defect along the warp or weft of the fabric. S42: Frequency Domain Texture Preservation Filtering: Based on frequency domain texture preservation constraints, frequency domain filtering is applied to the edge region of defects to suppress the periodic structural disturbance of the background caused by defect embedding, ensuring that the texture phase of the fabric around the defect is consistent with the original normal fabric. Through the joint optimization of the above two sub-steps, a refined second synthetic flawed image is output; S5: Closed-loop iterative optimization: The second synthesized defect image is fed back into the defect detection model to obtain the updated reward signal. Steps S3 to S4 are executed repeatedly to form a closed adaptive iterative loop of coarse generation, detection feedback, geometric texture refinement, and re-detection until the reward signal converges or the preset number of iterations is reached. In each iteration, the generator continuously adjusts its internal parameters based on the gradient information of the reward signal. S6: Final Model Training and Detection: The final synthesized defect image that has reached the convergence condition is added to the training dataset, and the defect detection model is retrained to obtain the final visual detection model for fabric printing defects, which is used for real-time defect detection of the fabric image to be tested.

[0007] The present invention is further configured such that: the performance evaluation index data in step S3 also includes the positioning accuracy index of the detection model, wherein the positioning accuracy index is the intersection-over-union ratio or the mean average accuracy between the predicted defect area and the actual defect area.

[0008] The present invention is further configured such that: the reinforcement learning policy gradient method in step S3 is a proximal policy optimization algorithm, which is used to directly transmit the reward signal to the network parameter gradient update of the generator.

[0009] The present invention is further configured such that: the periodic geometric prior constraint in step S41 is constructed based on the warp density, weft density or weave structure diagram of the fabric, and the geometric shape adjustment includes morphological expansion, skeleton extraction or spline interpolation operations on the defect area to ensure the natural extension of the defect along the fabric texture direction.

[0010] The present invention is further configured such that: in step S42, the frequency domain texture preservation constraint uses fast Fourier transform to extract the spectral amplitude and phase information of the normal fabric image, and replaces the spectral amplitude of the defect edge region with the spectral amplitude of the corresponding normal fabric region to suppress background periodic structural disturbances.

[0011] The present invention is further configured such that the convergence condition of the reward signal in step S5 is: in continuous iterations, the improvement of the performance evaluation index data is less than a preset threshold.

[0012] The present invention is further configured such that: the generator is a deep convolutional generative adversarial network based on attention mechanism and adaptive instance normalization; the encoder part of the generator uses dilated convolution to expand the receptive field of the defect region; and the decoder part of the generator introduces skip connections to preserve high-frequency texture details of the fabric background.

[0013] The present invention is further configured such that the target detection network integrates a self-attention module and a feature pyramid structure during the training process to enhance the detection capability of defects at different scales.

[0014] A visual inspection system for fabric printing and dyeing defects includes: Data acquisition and initial training module: used to acquire fabric sample images containing real defects and normal fabric sample images without defects, build an initial training dataset, and perform the first stage of training on the initial generative adversarial network to obtain the initial generator. Roughness Defect Generation Module: Used by the initial generator to generate a first synthetic defect image with initial roughness defect, taking a normal fabric sample image without defects and its fabric texture background information as input; The detection performance reward feedback module is used to input the first synthetic defect image into the pre-trained defect detection model for detection testing, collect at least one performance evaluation index data in the detection test, the performance evaluation index data includes one or more of defect detection rate, false detection rate, and average detection accuracy, and use the performance evaluation index data as a reward signal to feed back to the initial generator through the policy gradient method in reinforcement learning to guide the subsequent update direction of the generator parameters. The geometric texture refinement module is used to perform periodic geometric prior adjustment and frequency domain texture preservation filtering after the generator receives the reward signal. The periodic geometric prior adjustment is based on the periodic geometric prior constraints of the fabric and adjusts the geometric shape of the defect region in the first synthetic defect image to maintain the linear continuity of the defect along the warp or weft of the fabric. The frequency domain texture preservation filtering is based on the frequency domain texture preservation constraints and performs frequency domain filtering on the edge region of the defect to suppress the periodic structural disturbance of the background caused by defect embedding and ensure that the texture phase of the fabric around the defect is consistent with the original normal fabric. The refined second synthetic defect image is output through joint optimization. Closed-loop iterative optimization module: used to feed the second synthetic defect image back into the defect detection model to obtain an updated reward signal, and repeatedly perform the detection performance reward feedback and geometric texture refinement operations to form a closed adaptive iterative loop of coarse generation, detection feedback, geometric texture refinement, and re-detection until the reward signal converges or the preset number of iterations is reached. In each iteration, the generator continuously adjusts its internal parameters according to the gradient information of the reward signal. The final model training and detection module is used to add the final synthesized defect images that have reached the convergence condition to the training dataset, retrain the defect detection model, and obtain the final visual detection model for fabric printing defects, which is used to perform real-time defect detection on the fabric images to be tested.

[0015] In summary, the present invention has the following beneficial effects: 1. By introducing the periodic geometric prior of the fabric, the morphology of the generated defects is adjusted in a directional manner, so that the defect area extends naturally along the warp or weft direction. This overcomes the problems of blurred defect boundaries and arbitrary shapes in traditional methods. The synthesized defects are morphologically very close to the real defects, avoiding the detection model from learning the wrong defect pattern and improving the ability to identify real defects. 2. Based on frequency domain texture preservation constraints, the spectrum amplitude and phase information of normal fabric are used to filter the defect edge area, effectively suppressing high-frequency artifacts and periodic structural disturbances caused by defect embedding, maintaining the phase consistency of the fabric texture around the defect, thereby significantly reducing the false detection rate and positioning error of the detection model and enhancing the ability to accurately capture defect boundaries. 3. A closed adaptive iterative loop is constructed, consisting of coarse generation, detection feedback, geometric texture refinement, and re-detection. Detection performance metrics are directly fed back to the generator as reinforcement learning reward signals, achieving deep coupling between the generation process and the detection task. The generator can selectively adjust the geometric shape and texture consistency of defects based on the weaknesses of the detection model, continuously generating samples that are most challenging to the current model. This is especially effective for difficult samples such as subtle linear defects and weak contrast defects, driving continuous improvement in detection performance. 4. The synthesized defect images generated through iterative refinement are highly realistic and have coherent textures, effectively expanding the training dataset. This enables the retrained defect detection model to have a higher detection rate and positioning accuracy in real production lines, significantly enhancing the robustness and industrial applicability of the fabric printing and dyeing defect detection system. Attached Figure Description

[0016] Figure 1 This is a schematic diagram illustrating an application scenario of the visual detection method for fabric printing and dyeing defects of the present invention. Figure 2 This is a flowchart of the visual detection method for fabric printing and dyeing defects according to the present invention. Figure 3 This is a module connection diagram of the fabric printing and dyeing defect visual inspection system of the present invention. Detailed Implementation

[0017] The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] See Figure 1 , Figure 2 As shown, a visual inspection method for fabric printing and dyeing defects is proposed. This method can be implemented on a vision inspection industrial control computer equipped with a high-performance GPU computing card and an industrial line scan camera, so as to detect fabric surface defects in real time on the printing and dyeing production line.

[0019] Before implementation, this method first constructs an initial generative adversarial network and a pre-trained defect detection model. The generator employs a deep convolutional generative adversarial network based on attention mechanisms and adaptive instance normalization. The encoder incorporates dilated convolutional layers to expand the receptive field of defect regions while maintaining feature map resolution. The dilation rate is set in a cyclic structure of 1, 2, 3, 2, 1, enabling the output features to perceive a wider range of warp and weft weave relationships in the fabric. The decoder adds skip connections between layers of corresponding scales, directly transmitting the high-frequency texture details extracted by the encoder to the upsampling reconstruction layer of the decoder. After channel concatenation, these details are fed into subsequent convolutional layers to fully preserve the high-frequency weave texture of the normal fabric background. The discriminator uses a multi-scale PatchGAN structure to judge the authenticity of images at three different resolution scales.

[0020] The backbone network of the defect detection model uses a ResNet-50 or equivalent convolutional neural network pre-trained on ImageNet. Feature maps from the third residual stage onwards are introduced into a self-attention module to calculate long-range dependencies between spatial locations, enhancing the ability to model the global context of subtle defects. Simultaneously, the detection neck employs a feature pyramid structure, fusing high-level semantic features enhanced by self-attention with shallow detail features layer by layer from top to bottom, generating feature maps at four scales for detecting defects at different scales. The detection head uses anchor-box regression to output the defect category, bounding box coordinates, and confidence score.

[0021] The specific process of implementing this method is detailed below: First, data acquisition and initial training were performed. High-resolution line scan cameras deployed on the dyeing and printing production line continuously acquired fabric sample images containing real defects such as broken warp and weft threads, stains, holes, and blemishes, while simultaneously acquiring normal fabric sample images without any defects. All sample images were denoised, corrected for uneven illumination, and then uniformly scaled to 1024×1024 pixels. Pixel-level masking and bounding box annotations were performed on the real defect images, while the normal fabric images were labeled as defect-free. The real defect images were paired with the normal fabric images, and additional fabric texture background information was extracted from the normal fabric images. This texture background information included the spectral amplitude and phase maps obtained through two-dimensional Fourier transform, as well as the warp and weft density maps calculated based on spatial autocorrelation analysis. These maps, representing the periodic geometric priors of the fabric, were stitched together along the channel direction and used as the conditional input to the generator. The initial generative adversarial network is trained on the constructed training dataset using adversarial loss, reconstruction L1 loss and perceptual loss for the first stage. After optimization, an initial generator with preliminary defect synthesis capability is obtained.

[0022] After obtaining the initial generator, the roughness defect generation stage begins. A flawless normal fabric sample image is stitched together with the aforementioned fabric texture background information in the channel dimension and fed into the encoder of the initial generator. The generator dynamically selects the feature regions most relevant to the fabric texture direction through an attention module and uses adaptive instance normalization to modulate feature statistics to generate a first synthetic defect image with the initial roughness defect. In this synthetic image, although the defect areas show a general shape category, the defect boundaries are often blurred, and the defect shape does not strictly follow the warp and weft texture of the fabric. Texture breaks and high-frequency artifacts may appear at the edges due to the embedding operation.

[0023] Subsequently, the performance reward feedback step is initiated. The first synthesized flawed image is used as input and fed into the pre-trained flaw detection model for forward inference detection. In the detection output, several performance evaluation metrics are calculated: flaw detection rate (recall rate for various flaws), false alarm rate (false detection rate), average detection precision, and localization precision (cross-union ratio between predicted flawed regions and actual flawed labeled regions). To encourage the generator to produce challenging samples that expose the weaknesses of the detection model, the reinforcement learning objective is set to maximize the evaluation loss of the detection model on the synthesized image. Therefore, the reward signal actually fed back to the generator is negative R, or 1-R is used as the cost signal, thus inducing the generator to update in the direction of increasing the detection model's error, thereby forcing the detection model to improve its capabilities. This reward signal is processed through a proximal policy optimization algorithm to obtain the policy gradient. Specifically, the generator is treated as a policy network, and the distribution of its output synthetic flawed images is regarded as actions. The reward signal is calculated after generalized advantage estimation and importance sampling correction to obtain the advantage function used to update the generator network parameters. The weights of each layer of the generator are adjusted by maximizing the PPO truncated agent objective function to achieve stable and efficient policy gradient update.

[0024] After the generator receives gradient feedback based on the reward signal, it immediately performs geometric texture refinement. This refinement process is jointly completed by two sub-steps: periodic geometric prior adjustment and frequency domain texture-preserving filtering.

[0025] The specific implementation of periodic geometric prior adjustment is as follows: Warp and weft density parameters are extracted from the input fabric texture background information, and fabric principal direction constraints are applied to the defect area mask of the first synthesized defect image. First, the skeleton of the defect area is extracted using a binary mask to obtain the centerline describing the defect's direction. Based on the pre-calibrated fabric warp or weft principal direction vectors, the angle between the tangent direction of each local segment of the skeleton and the principal direction is calculated. When the angle exceeds a preset threshold of 15 degrees, piecewise cubic spline interpolation is used to redirect and smooth the skeleton, making its direction close to the nearest fabric principal direction. Then, based on the adjusted skeleton, the expansion width is determined according to the fabric density parameters, and a differentiable morphological dilation operation is used to regenerate the defect area outline, ensuring that the final defect area extends naturally along the warp and weft directions. For example, warp breaks strictly extend along the warp direction, and weft breaks strictly extend along the weft direction. The edges of blocky defects such as holes or stains also follow the surrounding yarn direction as much as possible, avoiding sharp transitions that conflict with the fabric's geometric texture.

[0026] The specific implementation of frequency domain texture-preserving filtering is as follows: First, the synthesized defect image and the corresponding original normal fabric image are subjected to Fast Fourier Transform (FFT) to obtain their respective spectral amplitudes and phases. A spectral weight mask corresponding to the defect edge region is constructed: In the spatial domain, the defect region mask is dilated to obtain an extended boundary band, which is then transformed to the frequency domain and smoothed using a Gaussian low-pass filter to generate a frequency domain weight map. Guided by this weight map, the spectral amplitude of the synthesized image corresponding to the defect edge region is partially replaced with the spectral amplitude at the same spatial frequency position of the normal fabric image, while the phase component remains unchanged. The spatial domain image is reconstructed through inverse Fourier transform to obtain the refined image after frequency domain texture-preserving filtering. This operation effectively suppresses high-frequency artifacts and background periodic structural disturbances caused by defect embedding, ensuring that the texture phase of the fabric surrounding the defect remains highly consistent with the original normal fabric, and the defect boundary naturally blends into the background texture.

[0027] After the above two sub-steps are combined for optimization, the refined second synthetic defect image is output. At this point, the generator's loss function, in addition to the original adversarial loss, also includes a policy gradient loss term from the detection feedback, as well as geometric continuity regularization and frequency domain consistency regularization terms. This allows the generator to maintain the geometric realism and texture coherence of the synthetic defects while evolving in a direction that increases the challenge of the detection model.

[0028] Next, the closed-loop iterative optimization phase begins. The newly generated second synthetic defect image is fed back into the defect detection model for re-detection, and the updated reward signal is calculated. A closed adaptive iterative loop of coarse generation, detection feedback, geometric texture refinement, and re-detection is executed repeatedly. In each iteration, the generator continuously fine-tunes its internal parameters based on gradient information obtained from the near-end policy optimization algorithm, while the detection model, with fixed weights, acts only as an evaluator. However, the synthetic images generated in each round can be accumulated for subsequent model retraining. The iteration termination condition is set as follows: in five consecutive iterations, the improvement in the performance evaluation index is less than a preset threshold of 0.002, or the total number of iterations reaches the set maximum of 300 iterations. When the termination condition is met, the quality of the obtained synthetic defect image tends to stabilize, with realistic defect morphology, coherent texture, and the ability to provide appropriately challenging training material targeting the weaknesses of the current detection model.

[0029] Finally, the final model training and testing are implemented. All synthetic defect images that have reached convergence are merged with the original real defect sample images, shuffled, and divided into an expanded training set and a validation set in an 8:2 ratio. Maintaining the original network structure of the detection model, it is retrained completely on the expanded training set using a stochastic gradient descent optimizer with a dynamic range, an initial learning rate of 0.001, and a cosine annealing strategy to decay the learning rate. Online data augmentation techniques such as random cropping, horizontal flipping, color dithering, and simulated lighting changes are also employed. After training, the model is evaluated on the validation set to obtain the final visual detection model for fabric printing defects. This model is deployed to an industrial computer on the production line, which reads the image stream of the fabric to be tested from a line scan camera in real time. Each frame is preprocessed and then fed into the detection model, outputting the category, location bounding box, and confidence score of all defects. Based on the results, it can drive inkjet marking or alarm devices to achieve high-precision online defect detection.

[0030] See Figure 3 As shown, based on the same technical concept, this embodiment also provides a visual inspection system for fabric printing and dyeing defects. This system includes software functional modules that implement the steps of the above method, specifically including a data acquisition and initial training module, a rough defect generation module, a detection performance reward feedback module, a geometric texture refinement module, a closed-loop iterative optimization module, and a final model training and detection module. The function of each module corresponds one-to-one with the steps of the above method. On an industrial computer, the central processing unit and graphics processing unit work together to complete the real-time defect detection output of the input fabric image. The geometric texture refinement module in the system integrates a periodic geometric prior adjustment submodule and a frequency domain texture-preserving filtering submodule, respectively constraining the extension of defects along the warp and weft directions of the fabric and preserving the phase consistency of the edge texture. Its specific implementation logic is completely consistent with the method process described in this embodiment and will not be repeated here.

[0031] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principle of the present invention should also be considered within the scope of protection of the present invention.

Claims

1. A method for visual inspection of defects in cloth printing, characterized in that: Includes the following steps: S1. Data Collection and Initial Training: Collect fabric sample images containing real defects and normal fabric sample images without defects to construct the initial training dataset, and perform the first stage of training on the initial generative adversarial network to obtain the initial generator. S2: Roughness defect generation: Using the initial generator, a first synthetic defect image with initial roughness defect is generated by taking a normal fabric sample image without defects and its fabric texture background information as input. S3: Detection performance reward feedback: The first synthetic defect image is input into the pre-trained defect detection model for detection testing. At least one performance evaluation index data in the detection test is collected. The performance evaluation index data includes one or more of the following: defect detection rate, false detection rate, and average detection accuracy. The performance evaluation index data is used as a reward signal and fed back to the initial generator through the policy gradient method in reinforcement learning to guide the subsequent update direction of the generator parameters. S4: Geometric Texture Refinement: After receiving the reward signal, the generator performs the following two sub-steps: S41: Periodic geometric prior adjustment: Based on the periodic geometric prior constraints of the fabric, the geometric shape of the defect area in the first synthetic defect image is adjusted to maintain the linear continuity of the defect along the warp or weft of the fabric. S42: Frequency Domain Texture Preservation Filtering: Based on frequency domain texture preservation constraints, frequency domain filtering is applied to the edge region of defects to suppress the periodic structural disturbance of the background caused by defect embedding, ensuring that the texture phase of the fabric around the defect is consistent with the original normal fabric. Through the joint optimization of the above two sub-steps, a refined second synthetic flawed image is output; S5: Closed-loop iterative optimization: The second synthetic defect image is fed back into the defect detection model to obtain the updated reward signal. Steps S3 to S4 are executed repeatedly to form a closed adaptive iterative loop of rough generation, detection feedback, geometric texture refinement, and re-detection until the reward signal converges or the preset number of iterations is reached. In each iteration, the generator continuously adjusts its internal parameters based on the gradient information of the reward signal; S6: Final Model Training and Detection: The final synthesized defect image that has reached the convergence condition is added to the training dataset, and the defect detection model is retrained to obtain the final visual detection model for fabric printing defects, which is used for real-time defect detection of the fabric image to be tested.

2. The method for visual inspection of fabric printing and dyeing defects according to claim 1, characterized in that: The performance evaluation index data in step S3 also includes the positioning accuracy index of the detection model, which is the intersection-over-union ratio or average accuracy between the predicted defect area and the actual defect area.

3. The method for visual inspection of fabric printing and dyeing defects according to claim 1, characterized in that: The reinforcement learning policy gradient method in step S3 is a proximal policy optimization algorithm, which is used to directly transmit the reward signal to the network parameter gradient update of the generator.

4. The method for visual inspection of fabric printing and dyeing defects according to claim 1, characterized in that: The periodic geometric prior constraints in step S41 are constructed based on the warp density, weft density, or weave pattern of the fabric. The geometric shape adjustment includes morphological expansion, skeleton extraction, or spline interpolation operations on the defect area to ensure the natural extension of the defect along the fabric texture direction.

5. The method for visual inspection of fabric printing and dyeing defects according to claim 1, characterized in that: In step S42, the frequency domain texture preservation constraint uses Fast Fourier Transform to extract the spectral amplitude and phase information of the normal fabric image, and replaces the spectral amplitude of the defect edge region with the spectral amplitude of the corresponding normal fabric region to suppress background periodic structural disturbances.

6. The fabric printing and dyeing defect visual inspection method according to claim 1, characterized in that: The convergence condition for the reward signal in step S5 is that, in continuous iterations, the improvement of the performance evaluation index data is less than a preset threshold.

7. The method for visual inspection of fabric printing and dyeing defects according to claim 1, characterized in that: The generator is a deep convolutional generative adversarial network based on attention mechanism and adaptive instance normalization. The encoder part of the generator uses dilated convolution to expand the receptive field of the defect area, and the decoder part of the generator introduces skip connections to preserve high-frequency texture details of the fabric background.

8. The fabric printing and dyeing defect visual inspection method according to claim 1, characterized in that: The object detection network incorporates a self-attention module and a feature pyramid structure during training to enhance its ability to detect defects at different scales.

9. A system for visual inspection of fabric printing defects, for implementing the method according to any one of claims 1 to 8, characterized in that it comprises: include: Data acquisition and initial training module: used to acquire fabric sample images containing real defects and normal fabric sample images without defects, build an initial training dataset, and perform the first stage of training on the initial generative adversarial network to obtain the initial generator. Roughness Defect Generation Module: Used by the initial generator to generate a first synthetic defect image with initial roughness defect, taking a normal fabric sample image without defects and its fabric texture background information as input; The detection performance reward feedback module is used to input the first synthetic defect image into the pre-trained defect detection model for detection testing, collect at least one performance evaluation index data in the detection test, the performance evaluation index data includes one or more of defect detection rate, false detection rate, and average detection accuracy, and use the performance evaluation index data as a reward signal to feed back to the initial generator through the policy gradient method in reinforcement learning to guide the subsequent update direction of the generator parameters. The geometric texture refinement module is used to perform periodic geometric prior adjustment and frequency domain texture preservation filtering after the generator receives the reward signal. The periodic geometric prior adjustment is based on the periodic geometric prior constraints of the fabric and adjusts the geometric shape of the defect region in the first synthetic defect image to maintain the linear continuity of the defect along the warp or weft of the fabric. The frequency domain texture preservation filtering is based on the frequency domain texture preservation constraints and performs frequency domain filtering on the edge region of the defect to suppress the periodic structural disturbance of the background caused by defect embedding and ensure that the texture phase of the fabric around the defect is consistent with the original normal fabric. The refined second synthetic defect image is output through joint optimization. Closed-loop iterative optimization module: used to feed the second synthetic defect image back into the defect detection model to obtain an updated reward signal, and repeatedly perform the detection performance reward feedback and geometric texture refinement operations to form a closed adaptive iterative loop of coarse generation, detection feedback, geometric texture refinement, and re-detection until the reward signal converges or the preset number of iterations is reached. In each iteration, the generator continuously adjusts its internal parameters according to the gradient information of the reward signal. The final model training and detection module is used to add the final synthesized defect images that have reached the convergence condition to the training dataset, retrain the defect detection model, and obtain the final visual detection model for fabric printing defects, which is used to perform real-time defect detection on the fabric images to be tested.