Fabric texture defect repairing method and device based on generative adversarial network
By adopting a two-stage repair method based on generative adversarial networks, the problem of insufficient visual continuity and texture consistency in complex texture structures in traditional texture repair methods is solved, and efficient and stable repair of fabric texture defects is achieved. It is applicable to a variety of fabrics such as cotton, silk, and wool.
Patent Information
- Application Number
- CN202511041155.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-28
- Publication Date
- 2025-10-31
AI Technical Summary
Traditional texture restoration methods struggle to accurately capture and reconstruct the essential features of complex texture structures, resulting in defects in visual continuity and texture consistency. This is especially true when dealing with large-area defects, where texture discontinuities and unnatural boundaries are common problems.
A two-stage repair method based on generative adversarial networks is adopted. First, cross-domain feature unification is achieved through gradient inversion layer and domain confusion mechanism. Then, similarity retrieval is performed using fabric texture semantic memory. Finally, structural reconstruction and detail optimization are performed by combining orientation-aware convolutional layer and wavelet multi-scale reconstruction to ensure texture orientation consistency and seamless connection.
It effectively eliminates the visual abrupt change between the repaired area and the original area, achieving a seamless and natural transition effect, improving the repair quality of large-area defects, and optimizing computational efficiency. It is suitable for stable repair of different fabric types.
Smart Images

Figure CN120876567A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of defect repair technology, and in particular to a method and apparatus for repairing fabric texture defects based on generative adversarial networks. Background Technology
[0002] Traditional texture restoration methods mainly rely on simple pixel filling and sample-based texture synthesis techniques. These methods often exhibit significant limitations when dealing with complex texture structures. In particular, when fabric textures exhibit periodicity, directionality, and multi-scale characteristics, traditional methods struggle to accurately capture and reconstruct the essential features of the texture, resulting in significant defects in visual continuity and texture consistency in the restoration results.
[0003] Furthermore, handling large-area defects in fabric texture repair has always been a technical challenge. Existing methods lack effective multi-stage processing mechanisms, making it difficult to maintain both the integrity of the texture structure and the quality of details. Traditional single-stage repair methods are prone to problems such as texture discontinuity and unnatural boundaries when dealing with large-area defects, especially against complex texture backgrounds, where the visual difference between the repaired area and the surrounding normal texture is particularly noticeable. At the same time, existing technologies lack effective utilization of texture direction information and cannot fully consider the directional characteristics of the fabric texture, resulting in insufficient consistency in texture direction in the repair results. Summary of the Invention
[0004] The main objective of this invention is to provide a method and apparatus for repairing fabric texture defects based on generative adversarial networks. This invention effectively eliminates visual abrupt changes between the repaired area and the original area, achieving a seamless and natural transition effect, and optimizing computational efficiency while ensuring repair quality.
[0005] To achieve the above objectives, this invention provides a method for repairing fabric texture defects based on generative adversarial networks, comprising the following steps: The defective fabric image to be repaired is decomposed to obtain the fabric texture direction feature matrix and the defect area localization mask. The fabric texture direction feature matrix is subjected to cross-domain feature unification processing through a gradient inversion layer to obtain a unified feature code. Based on the unified feature encoding, a similarity search is performed in the fabric texture semantic memory to obtain the best matching texture reference feature; Based on the best matching texture reference features, the defect region location mask and the defect fabric image are input into the first-stage coarse repair generator for structural reconstruction to obtain the initial fabric repair image. The initial fabric restoration image is input into the second-stage fine restoration generator for wavelet multi-scale detail optimization and boundary fusion correction to obtain the target fabric restoration image.
[0006] Optionally, in a first implementation of the first aspect of the present invention, the step of decomposing the defective fabric image to be repaired to obtain a fabric texture direction feature matrix and a defect region localization mask includes: The defective fabric image to be repaired is sized and standardized to obtain a standard fabric image. The standard fabric image is then enhanced in contrast by histogram equalization to obtain a preprocessed standard fabric image. The preprocessed standard fabric image is input into a Gabor filter bank for multi-directional texture feature decomposition to obtain the filter response amplitude matrix. The dominant texture direction and intensity information of each pixel are calculated based on the filter response amplitude matrix, and a fabric texture direction feature matrix is constructed based on the dominant texture direction and intensity information. The preprocessed standard fabric image is input into the DeepLabV3+ semantic segmentation network for pixel-level defect detection to obtain the defect region localization mask.
[0007] Optionally, in a second implementation of the first aspect of the present invention, the step of inputting the preprocessed standard fabric image into a DeepLabV3+ semantic segmentation network for pixel-level defect detection to obtain a defect region localization mask includes: The preprocessed standard fabric image is input into the ResNet backbone network in the DeepLabV3+ semantic segmentation network for multi-level feature extraction to obtain the fabric texture feature map. The fabric texture feature map is input into the void space pyramid pooling module for multi-scale contextual information fusion to obtain an enhanced feature map. The enhanced feature map is input into the decoder for resolution restoration processing to obtain a full-resolution semantic feature map, and the full-resolution semantic feature map is subjected to pixel-level binary classification processing to obtain a pixel-level defect probability distribution map. The pixel-level defect probability distribution map is binarized to obtain the defect area location mask that identifies the defect area.
[0008] Optionally, in a third implementation of the first aspect of the present invention, the step of performing cross-domain feature unification processing on the fabric texture direction feature matrix through a gradient inversion layer to obtain unified feature encoding includes: The fabric texture direction feature matrix is input into the gradient inversion layer for feature transfer, resulting in the transferred texture feature matrix. The transmitted texture feature matrix is input into a texture domain classifier for domain category recognition processing to obtain a domain classification probability vector. The domain confusion loss is calculated based on the domain classification probability vector, and the gradient is reversed during backpropagation based on the domain confusion loss to obtain a unified feature code.
[0009] Optionally, in a fourth implementation of the first aspect of the present invention, the step of performing a similarity retrieval in the fabric texture semantic memory based on the unified feature encoding to obtain the best matching texture reference feature includes: The cosine similarity between the unified feature code and the N texture domain feature prototypes stored in the fabric texture semantic memory is calculated to obtain the similarity numerical matrix between the unified feature code and each texture domain feature prototype. Based on the similarity numerical matrix, a candidate texture feature prototype set is obtained by sorting and filtering in descending order. Calculate the attention weight coefficient for each texture domain feature prototype in the candidate texture feature prototype set to obtain the attention weight vector; The candidate texture feature prototype set is weighted and fused according to the attention weight vector to obtain the best matching texture reference feature that fuses the texture features of the current defective fabric.
[0010] Optionally, in a fifth implementation of the first aspect of the present invention, the step of inputting the defect region localization mask and the defect fabric image into a first-stage coarse repair generator for structural reconstruction based on the best-matching texture reference features to obtain an initial fabric repair image includes: The best matching texture reference feature, the defect region localization mask and the defective fabric image are spliced and fused along the channel dimension to obtain a multi-channel input feature map. The multi-channel input feature map is input into the encoder of the first-stage coarse repair generator for downsampling feature extraction to obtain a multi-scale encoded feature map. The multi-scale encoded feature map is input into a direction-aware convolutional layer for texture direction guidance processing to obtain a direction-optimized encoded feature map. The optimized coded feature map is input into the decoder for upsampling texture reconstruction to obtain the initial fabric repair image.
[0011] Optionally, in a sixth implementation of the first aspect of the present invention, the step of inputting the multi-scale encoded feature map into a direction-aware convolutional layer for texture direction guidance processing to obtain a direction-optimized encoded feature map includes: The multi-scale encoded feature map is spatially matched with the fabric texture direction feature matrix to obtain a direction guidance matrix of the same size as the multi-scale encoded feature map. Based on the texture direction angle information in the direction guidance matrix, the convolution kernel parameters of the direction-aware convolutional layer are dynamically adjusted, and the corresponding convolution kernel weights are rotated according to the direction angle value of each pixel position to obtain a dynamic convolution kernel set. The multi-scale encoded feature map is subjected to pixel-wise adaptive convolution operation with the dynamic convolution kernel set to obtain an orientation-aligned texture feature response map; The texture feature response map with the alignment is subjected to texture structure continuity enhancement processing to obtain the orientation-optimized encoded feature map.
[0012] Optionally, in the seventh implementation of the first aspect of the present invention, the step of inputting the initial fabric restoration image into a second-stage fine restoration generator for wavelet multi-scale detail optimization and boundary fusion correction to obtain the target fabric restoration image includes: The initial fabric repair image, the defective fabric image, and the defective region localization mask are input into the three-branch fusion network of the second-stage fine repair generator to integrate multiple input features and obtain a fused input feature map. The fused input feature map is subjected to three-level wavelet decomposition to obtain a multi-scale wavelet feature representation; The multi-scale wavelet feature representation is input into the fine-grained inpainting generator network for detail optimization to obtain a finely inpainted texture image. The boundary fusion correction is performed on the original fabric region in the finely repaired texture image and the defective fabric image to obtain the target fabric repair image.
[0013] Optionally, in an eighth implementation of the first aspect of the present invention, the step of inputting the multi-scale wavelet feature representation into a fine-grained inpainting generator network for detail optimization to obtain a fine-grained inpainted texture image includes: The multi-scale wavelet feature representation is input into the D residual blocks of the fine repair generator network for concatenated feature extraction to obtain the deep residual feature representation. A self-attention layer is added between the D residual blocks to perform spatial attention enhancement processing on the deep residual feature representation, resulting in an attention-enhanced texture feature map; The texture consistency constraint loss function is calculated based on the attention-enhanced texture feature map to obtain the comprehensive texture constraint loss value; Based on the comprehensive texture constraint loss value, the parameter weights of the fine-grained inpainting generator network are updated using the backpropagation algorithm, and the fine-grained inpainting generator network is used to generate a fine-grained inpainting texture image.
[0014] The present invention also provides a fabric texture defect repair device based on generative adversarial networks, comprising: The decomposition module is used to decompose the defective fabric image to be repaired, and obtain the fabric texture direction feature matrix and the defect area localization mask. The processing module is used to perform cross-domain feature unification processing on the fabric texture direction feature matrix through a gradient inversion layer to obtain a unified feature code. The retrieval module is used to perform similarity retrieval in the fabric texture semantic memory based on the unified feature encoding to obtain the best matching texture reference feature; The structure reconstruction module is used to input the defect region positioning mask and the defect fabric image into the first-stage coarse repair generator based on the best matching texture reference features to perform structure reconstruction and obtain the initial fabric repair image. The detail optimization module is used to input the initial fabric repair image into the second-stage fine repair generator for wavelet multi-scale detail optimization and boundary fusion correction to obtain the target fabric repair image.
[0015] In summary, the technical solution provided by this invention effectively eliminates domain differences between different texture types through gradient inversion layers and domain obfuscation mechanisms, significantly enhancing cross-domain generalization capabilities. This allows the fabric texture defect repair method to maintain stable repair performance when handling different fabric types such as cotton, silk, and wool. The adoption of a two-stage progressive repair architecture greatly improves the repair quality of large-area defects. The first stage focuses on texture structure skeleton reconstruction, while the second stage optimizes details, effectively solving the problems of structural discontinuity and missing details in traditional single-stage methods. The establishment of a fabric texture semantic memory library enables effective accumulation and transfer of cross-domain texture knowledge. The direction-aware convolutional layer ensures texture direction consistency, and the multi-scale reconstruction strategy based on wavelet transform achieves layer-by-layer texture reconstruction from coarse to fine. Simultaneously, the Gaussian filter boundary fusion correction mechanism effectively eliminates visual abrupt changes between the repaired area and the original area, achieving a seamless and natural transition effect, optimizing computational efficiency while ensuring repair quality. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the steps of a fabric texture defect repair method based on generative adversarial networks in one embodiment of the present invention; Figure 2 This is a structural block diagram of a fabric texture defect repair device based on generative adversarial networks in one embodiment of the present invention.
[0017] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0019] Reference Figure 1 This embodiment provides a method for repairing fabric texture defects based on generative adversarial networks, including the following steps: S1, decompose the defective fabric image to be repaired to obtain the fabric texture direction feature matrix and the defect area localization mask. The process involves standardizing the dimensions of the defective fabric images to be repaired, transforming them into uniform 512×512 pixel square images to obtain standard fabric images with a unified scale. Histogram equalization is then introduced to redistribute the brightness distribution of these standard images, enhancing image contrast and effectively improving the discernibility of subtle textures and the saliency of local texture structures, resulting in preprocessed standard fabric images. These preprocessed standard fabric images are then input into a pre-constructed Gabor filter bank for multi-directional texture feature response extraction. This filter bank contains Gabor kernel functions with eight directional angles (e.g., 0°, 22.5°, 45°, 67.5°, 90°, 112.5°, 135°, 157.5°), corresponding to the dominant arrangement directions of fabric textures. Each Gabor filter performs response operations on a local region of the image in the spatial domain, thereby extracting the filter response intensity in multiple directions and generating the corresponding response amplitude matrix. Based on all directional response matrices, the direction corresponding to the maximum response amplitude is used as the dominant texture direction of the pixel. Simultaneously, the amplitude value corresponding to this direction is used as a local texture intensity index. An overall fabric texture direction feature matrix is constructed using the direction angle and intensity value of each pixel as elements, forming a two-dimensional tensor data structure with directional marking and intensity distribution characteristics. Meanwhile, the same preprocessed standard fabric image is input into the trained DeepLabV3+ semantic segmentation network model. This model employs dilated convolution and a multi-scale context aggregation structure, enabling pixel-level segmentation and recognition of defective regions in the image. By generating a binary mask image of the same size as the image, the pixel positions corresponding to defective regions are marked as 1, while normal regions are marked as 0, thus obtaining the defective region localization mask.
[0020] S2, through the gradient inversion layer, performs cross-domain feature unification processing on the fabric texture direction feature matrix to obtain unified feature encoding; Specifically, the fabric texture direction feature matrix is input into the gradient inversion layer for uninterrupted forward propagation. During forward propagation, the gradient inversion layer does not apply any numerical transformations to the data, directly passing the input texture direction features to the next processing module in their original state, resulting in the propagated texture feature matrix. This propagated texture feature matrix is then input into a pre-constructed texture domain classifier. The texture domain classifier consists of five convolutional layers with the number of channels increasing from shallow to deep as 64, 128, 256, 512, and 1024, respectively. Each layer has a 3×3 kernel, and each layer is followed by a LeakyReLU activation function to enhance non-linear expressiveness. This classifier encodes and extracts the input texture features layer by layer, outputting a domain classification probability vector of length K, where K is the total number of fabric types, for example, including cotton, silk, wool, linen, chemical fiber, blended fabrics, knitted fabrics, and woven fabrics—a total of eight categories. Each element in the domain classification probability vector represents the predicted probability that the input texture belongs to the corresponding category. The entropy value of the domain classification probability vector is calculated, and a domain confusion loss function is constructed. By maximizing the entropy value of the output probability distribution, the classifier is made as incapable as possible of determining which specific fabric type the input texture feature belongs to during training. This forces the generator to extract texture feature representations that are independent of the domain. During the backpropagation phase, the gradient of the domain confusion loss is transmitted back to the gradient reversal layer. At this time, the gradient reversal layer performs a sign reversal operation on the incoming error term, multiplying the gradient by a negative weight coefficient (dynamically set between 0.1 and 2.0), so that the generator update direction is opposite to the classifier's target, forming an adversarial training mechanism. Through this reversal optimization strategy, the generator learns a consistent and unified feature encoding across fabric types.
[0021] S3. Based on the unified feature encoding, a similarity search is performed in the fabric texture semantic memory to obtain the best matching texture reference feature; It should be noted that the unified feature code is input into the semantic memory module. This memory pre-constructs and dynamically maintains representative feature prototypes for multiple texture domains, with a total number of N. Each prototype represents the semantic feature expression of a typical fabric texture. These prototypes are organized and managed according to fabric classification, covering major types including cotton, silk, wool, linen, chemical fiber, blended fabrics, knitted fabrics, and woven fabrics. During the matching phase of the memory, the unified feature code is compared with all N texture domain feature prototypes using cosine similarity calculations, resulting in a similarity matrix composed of N similarity values. This similarity measures the degree of directional consistency between the texture code of the current image to be repaired and each known prototype in high-dimensional space. The higher the similarity, the closer the semantic style of the current code is to that prototype. All values in the similarity matrix are sorted in descending order and filtered to select the top-ranked prototypes to form a candidate texture feature prototype set. The first k prototypes (e.g., k=5) are selected to ensure a balance between texture diversity and matching accuracy. After constructing the candidate set, to optimize the multi-prototype fusion effect, attention weights are calculated for each candidate prototype based on its corresponding similarity value. The similarity of each prototype is indexed and normalized to form an attention weight vector. A weighted summation operation is then performed on each prototype vector in the candidate set based on this attention weight vector to obtain an optimal matching texture reference feature that fuses the texture features of the current defective fabric while maximizing semantic consistency and style continuity.
[0022] S4. Based on the best matching texture reference features, the defect area localization mask and the defect fabric image are input into the first-stage coarse repair generator for structural reconstruction to obtain the initial fabric repair image. Specifically, the best-matching texture reference features are concatenated and fused with the image of the defective fabric to be repaired and the corresponding defect region localization mask in the channel dimension to construct a multi-channel input feature map containing structural information, texture style information, and defect spatial indication information. The reference features serve as prior style guidance, the mask image marks the defect boundary positions, and the original image provides contextual texture data. This multi-channel input feature map is then fed into the encoder structure of the first-stage coarse repair generator for layer-by-layer downsampling processing. This encoder consists of five downsampling modules, each composed of a convolutional layer, a batch normalization layer, and a nonlinear activation function. It extracts semantic structural information at different scales in the image by progressively increasing the number of channels layer by layer, forming a multi-scale encoded feature map. This multi-scale encoded feature map is then fed into a direction-aware convolutional layer for processing. This direction-aware convolutional layer reads the pre-extracted texture direction feature map and dynamically adjusts the convolution kernel weight direction under the guidance of this direction information. This makes the convolution operation more focused on the response along the dominant texture direction, thereby repairing structurally interrupted regions while maintaining texture continuity, and outputting a direction-optimized encoded feature map. The oriented optimized encoded feature map is input into the decoder structure of the coarse restoration generator for upsampling reconstruction. The decoder adopts a structure symmetrical to the encoder. It gradually restores the feature map size to the original image size through transposed convolution or upsampling operations. In each decoding layer, the features of the corresponding encoding layer are fused to achieve the gradual restoration of feature details. Finally, the initial fabric restoration image is output.
[0023] S5. Input the initial fabric restoration image into the second-stage fine restoration generator for wavelet multi-scale detail optimization and boundary fusion correction to obtain the target fabric restoration image.
[0024] In this process, the initial fabric restoration image, the original defective fabric image, and the corresponding defect region localization mask are input into the three-branch fusion network structure of the second-stage fine restoration generator. This network performs feature encoding and preliminary processing on the three types of inputs separately, and then effectively integrates them in the feature space to form a fused input feature map. The fused input feature map undergoes three-level wavelet decomposition, using the Daubechies-4 wavelet basis function to extract the low-frequency components and high-frequency details in three directions (horizontal, vertical, and diagonal) of the image level by level, forming a wavelet feature representation with multi-scale resolution capabilities. This representation can capture the texture variation features at different scales in the fabric texture, helping the generator to perform restoration processing at both the local and global levels. The multi-scale wavelet feature representation is input into the deep network of the fine restoration generator for detail optimization. This network integrates an attention mechanism and a multi-scale reconstruction strategy, dynamically calculating the importance weights of features at each scale and weighting them in the channel dimension to emphasize key texture details and suppress redundant information, thereby enhancing the texture accuracy and directional consistency of the edge transition areas in the restored image and outputting a finely restored texture image. The original fabric region in the finely repaired texture image and the defective fabric image is fused and corrected by boundary fusion. This correction process is based on the boundary position marked by the defect region mask. The repair edge is fused at the pixel level by hybrid filtering and blur transition algorithm, so as to effectively eliminate artifacts such as color jump, texture discontinuity or abrupt contour between the repaired area and the non-defective area, and obtain the target fabric repair image.
[0025] In one example, the defective fabric image to be repaired is decomposed to obtain the fabric texture direction feature matrix and the defect region localization mask, including: The defective fabric image to be repaired is sized and normalized to obtain a standard fabric image. The contrast of the standard fabric image is then enhanced by histogram equalization to obtain a preprocessed standard fabric image. The preprocessed standard fabric image is input into the Gabor filter bank for multi-directional texture feature decomposition to obtain the filter response amplitude matrix. The dominant texture direction and intensity information of each pixel are calculated based on the filter response amplitude matrix, and the fabric texture direction feature matrix is constructed based on the dominant texture direction and intensity information. The preprocessed standard fabric image is input into the DeepLabV3+ semantic segmentation network for pixel-level defect detection, and the defect region localization mask is obtained.
[0026] In this example, all input original defective fabric images are adjusted to a uniform resolution of 512×512 pixels. Bilinear interpolation is used for image scaling to preserve the original proportions of the image structure as much as possible, resulting in a standard-sized fabric image. To improve the recognizability of detailed textures in the fabric image, image enhancement is performed on the standard-sized image by introducing histogram equalization. This method reconstructs the grayscale distribution of the image, making the brightness levels more evenly distributed across the entire grayscale range, thereby enhancing the overall contrast of the image and obtaining a preprocessed standard fabric image. The preprocessed standard fabric image is then input into a Gabor filter bank for multi-directional texture feature decomposition. The system introduces a set of Gabor filter kernels consisting of eight different directions, each corresponding to 0°, 22.5°, 45°, 67.5°, 90°, 112.5°, 135°, and 157.5°. By performing eight Gabor convolution operations on the input image, eight sets of directional response maps are obtained. Each response map reflects the texture response intensity and phase change in that direction. These directional response maps together form a filter response amplitude matrix, which characterizes the spatial distribution of texture in different directions in the image at the pixel level. Based on this response matrix, the system performs a maximum response direction extraction operation. At each pixel, the response intensities corresponding to the eight directions are compared, and the direction angle corresponding to the maximum value is selected as the dominant texture direction of that pixel. This maximum response value is recorded as the texture intensity. In this way, a texture direction map and a texture intensity map with the same size as the input image are constructed pixel by pixel. These two maps are structurally combined into a two-dimensional tensor, where each element contains both direction and amplitude information, thereby constructing the fabric texture direction feature matrix. Preprocessed standard fabric images are input into the DeepLabV3+ semantic segmentation network for pixel-level defect detection. This network employs a spatial pyramid pooling structure and dilated convolution strategy to enhance the model's ability to analyze multi-scale image content, and combines an encoder-decoder architecture to achieve contextual structure modeling and pixel-level reconstruction of the input image. During processing, DeepLabV3+ extracts high-level semantic features of the image through the backbone network while preserving low-level spatial location information, ultimately outputting a semantic label map with the same size as the original image. Each pixel in the label map is labeled with either 0 or 1, where a value of 1 represents a defective region identified by the network, and a value of 0 represents a normal region without defects, thus forming a defect region localization mask image.
[0027] In one example, a preprocessed standard fabric image is input into the DeepLabV3+ semantic segmentation network for pixel-level defect detection, resulting in a defect region localization mask, including: The preprocessed standard fabric image is input into the ResNet backbone network in the DeepLabV3+ semantic segmentation network for multi-level feature extraction to obtain the fabric texture feature map. The fabric texture feature map is input into the hollow spatial pyramid pooling module for multi-scale contextual information fusion to obtain the enhanced feature map; The enhanced feature map is input into the decoder for resolution restoration processing to obtain a full-resolution semantic feature map. Then, pixel-level binary classification processing is performed on the full-resolution semantic feature map to obtain a pixel-level defect probability distribution map. The defect location mask is obtained by binarizing the pixel-level defect probability distribution map to identify the defect area.
[0028] In this example, a preprocessed standard fabric image is input into the DeepLabV3+ deep semantic segmentation network. Leveraging its multi-layered structure perception capabilities and contextual fusion mechanism, the network extracts spatial distribution information of defect areas. DeepLabV3+ uses a ResNet backbone network, which effectively captures edge, texture, shape, and structural information in the image through residual connections and layer stacking. The fabric image is input into the ResNet backbone network, which spatially compresses the input image through initial convolutional and pooling layers. Subsequently, it progressively extracts high-order semantic features through a series of residual modules. This process maintains the stability of deep network training and the connectivity of early feature propagation, ensuring that low-level detailed texture information and high-level abstract semantics are simultaneously preserved and expressed. After processing by the ResNet backbone network, the output fabric texture feature map is a set of multi-level feature representation tensors that are downsampled in the spatial dimension and expanded in the channel dimension. This represents a comprehensive representation of the texture, structure, and potential defects of the current image under different receptive fields. To enhance the segmentation network's ability to perceive defects at different scales, fabric texture feature maps are input into a dilated spatial pyramid pooling module for multi-scale context fusion processing. This module contains several parallel dilated convolution branches, each operating on the input feature map using dilated convolution kernels with different dilation rates. This achieves spatial sampling and information aggregation across different receptive fields. These dilated convolutions expand the effective receptive field without increasing computational cost through a sparse sampling strategy, enabling the network to simultaneously perceive local texture information and a wider range of contextual structures. This is suitable for defect patterns in fabric textures with multiple scales and morphological differences. The dilated spatial pyramid pooling module also introduces a global average pooling path to aggregate overall image background information. Together with other dilated convolution branches, the processing results are channel-wise concatenated and fused to form an enhanced feature map. The enhanced feature map is input into the decoder module of DeepLabV3+ for progressive resolution restoration. The decoder mainly includes upsampling operations and low-level feature fusion mechanisms. On the one hand, it restores the feature map size to the full resolution of the original input image through transposed convolution or bilinear interpolation. On the other hand, it introduces low-level shallow features extracted in the early stages of the backbone network and fuses them with the current high-level semantic features. This ensures that the restored full-resolution semantic feature map possesses both accurate boundary details and high-order semantic judgment capabilities, thus avoiding edge blurring and detail loss caused by downsampling. The full-resolution semantic feature map is then input into a pixel-level classifier for pixel-by-pixel probability prediction. The classifier consists of one or more 1×1 convolutions, and its output dimension is the probability distribution value of each pixel belonging to the "defect" or "normal" class, forming a map of the same size as the original image. Figure 1A pixel-level defect probability distribution map is generated, where each pixel corresponds to a probability value between 0 and 1, representing the confidence level that it belongs to a defective region. The pixel-level defect probability distribution map is binarized, and a fixed or dynamic threshold, such as 0.5, is set as the judgment boundary. If the defect probability of a pixel is greater than or equal to the threshold, it is marked as a defect point and assigned a value of 1; otherwise, it is marked as a normal region and assigned a value of 0. The result is a binary mask map, i.e., a defect region location mask.
[0029] In one example, a gradient inversion layer is used to perform cross-domain feature unification processing on the fabric texture direction feature matrix, resulting in a unified feature encoding, including: The fabric texture direction feature matrix is input into the gradient inversion layer for feature transfer, resulting in the transferred texture feature matrix. The transmitted texture feature matrix is input into the texture domain classifier for domain category recognition processing to obtain the domain classification probability vector. The domain confusion loss is calculated based on the domain classification probability vector, and the gradient is reversed during backpropagation based on the domain confusion loss to obtain a unified feature code.
[0030] In this example, the fabric texture direction feature matrix is input into the gradient inversion layer for feature propagation. This layer does not perform any numerical or structural transformations on the feature matrix, but passes it to subsequent modules as is, maintaining the integrity of the information flow during forward propagation. This allows subsequent network layers to receive texture features normally for classification. However, it plays a core role during backpropagation, namely, constraining the generator by inverting the gradient direction, thereby guiding feature learning to have cross-domain invariance. The transmitted texture feature matrix is input into a texture domain classifier for category recognition. This classifier aims to determine the fabric type to which the current input texture feature belongs, including various types such as cotton, silk, linen, wool, chemical fiber, blended fabric, knitted fabric, and woven fabric. The classifier is built using a convolutional neural network structure, consisting of five convolutional layers. The number of channels in each convolutional layer is 64, 128, 256, 512, and 1024, respectively. The kernel size is uniformly 3×3. A batch normalization layer and a LeakyReLU activation function are added after each convolutional layer to enhance the nonlinear expressive power of the network and improve training stability. This network maps the input texture direction matrix to a feature space with global semantic representation capabilities through layer-by-layer feature abstraction and semantic extraction, and outputs a K-dimensional domain classification probability vector, where K represents the total number of predefined fabric categories. For example, eight major fabric types correspond to an 8-dimensional output vector. The value of each dimension represents the predicted probability of the input feature under the corresponding fabric category. The sum of all dimensions is 1, forming a normalized probability distribution. To achieve cross-domain feature unification, a domain confusion mechanism is introduced to keep the classifier "unrecognizable" of the specific fabric category of the input, thereby driving the generator to learn a domain-independent general feature representation. To this end, the system constructs a domain confusion loss function based on the domain classification probability vector output by the classifier. This loss function is essentially the realization of the maximum entropy objective, aiming to minimize the uncertainty of the classifier when judging input features. Therefore, a negative entropy function is used as the optimization objective. Numerically, this is achieved by taking the logarithm of the probability values for each category, weighting and summing the results, and then summing the results for all categories and taking the negative value. This forms the domain confusion loss value for the current sample. The larger this value, the more uncertain the current classifier is in recognizing the input, and the closer it is to a uniform distribution, reflecting the indiscriminability of texture features in the fabric domain space.Subsequently, during network training, as errors propagate back, the gradients generated by the domain confusion loss are passed back along the network layers to the gradient inversion layer. The gradient inversion layer plays a regulatory role at this stage; instead of remaining silent during backpropagation, it inverts the sign of the incoming gradients by multiplying the original gradients by a negative scaling factor. This factor is set between 0.1 and 2.0 and dynamically adjusted according to the training stage and model stability. This inversion operation creates an adversarial relationship between the classifier and the generator: the classifier attempts to distinguish the domain affiliation of various textures, while the generator is forced to adjust its feature extraction strategy to make its output "unrecognizable" by the classifier, thus incentivizing the generator to learn a feature encoding form with stronger generalization ability and inter-domain consistency. After several rounds of such adversarial training, the generator finally outputs a cross-domain consistent feature representation that is indistinguishable across fabric categories—a unified feature encoding.
[0031] In one example, a similarity search is performed in the fabric texture semantic memory based on the unified feature encoding to obtain the best matching texture reference features, including: The cosine similarity between the unified feature code and the N texture domain feature prototypes stored in the fabric texture semantic memory is calculated to obtain the similarity matrix between the unified feature code and each texture domain feature prototype. A candidate texture feature prototype set is obtained by sorting and filtering in descending order based on the similarity numerical matrix. Calculate the attention weight coefficient for each texture domain feature prototype in the candidate texture feature prototype set to obtain the attention weight vector; The candidate texture feature prototype set is weighted and fused according to the attention weight vector to obtain the best matching texture reference feature that fuses the texture features of the current defective fabric.
[0032] In this example, a unified feature code is input as a query vector into a semantic memory. This memory is a dynamically maintained, high-dimensional collection of texture feature prototypes, used to store representative encoding results from multiple fabric texture domains. Its construction is based on long-term accumulated sample learning and is categorized according to fabric type. Each category contains several feature prototype vectors, with a total number denoted as N. These prototypes have good discriminative power and semantic representativeness in the vector space, and can cover the main distribution structure of fabric textures to a certain extent. To achieve a matching metric between the unified feature code and the semantic memory, vector similarity is used as the primary metric. Cosine similarity measures the degree of directional consistency between two feature vectors by calculating the cosine of the angle between them in high-dimensional space. The closer the value is to 1, the more consistent the two vectors are in direction, meaning the current image to be repaired is closer to the texture style represented by a certain prototype. Specifically, the unified feature code, as a query vector, is used to perform cosine similarity calculations with each texture prototype vector in the memory, resulting in an N-dimensional similarity matrix. Each item in this matrix represents the similarity score between the query code and the corresponding i-th prototype vector. The similarity values in the similarity matrix are sorted in descending order to select the top k most similar prototype vectors as candidate texture feature prototype sets. An attention mechanism is introduced to assign different weight coefficients to each prototype vector in the candidate set, dynamically adjusting their participation ratio in the final fusion process. The attention weights are calculated based on similarity. The system exponentializes the similarity value corresponding to each candidate prototype to enhance the responsiveness of high-similarity terms. Then, a probability distribution vector is formed by normalizing all exponentially similarity values; this vector is the attention weight vector, with each dimension corresponding to a specific term in the candidate prototype. A larger value indicates a higher semantic fit between the prototype and the current image. Based on this attention weight vector and the candidate prototype set, the system uses a weighted fusion method to generate the final reference features. Each prototype vector in the candidate set is multiplied by its corresponding attention weight, and then summed element-wise to form a new fusion vector. This fusion vector is the best-matching texture reference feature that integrates the semantic information of the current defective fabric.
[0033] In one example, based on the best-matching texture reference features, the defect region localization mask and the defective fabric image are input into the first-stage coarse repair generator for structural reconstruction, resulting in an initial fabric repair image, including: The best matching texture reference features, defect region localization mask and defect fabric image are spliced and fused along the channel dimension to obtain a multi-channel input feature map. The multi-channel input feature map is input into the encoder of the first-stage coarse repair generator for downsampling feature extraction to obtain a multi-scale encoded feature map. The multi-scale encoded feature map is input into the orientation-aware convolutional layer for texture orientation guidance processing to obtain the orientation-optimized encoded feature map. The oriented optimized encoded feature map is input into the decoder for upsampling texture reconstruction to obtain the initial fabric restoration image.
[0034] In this example, the best-matching texture reference features, the defect region localization mask, and the original defective fabric image are concatenated and fused along the channel dimension to form a multi-channel input feature map. This multi-channel feature map is then input into the encoder of the first-stage coarse repair generator for progressive downsampling feature extraction. The encoder employs a multi-layer convolutional structure, with each layer containing convolution operations, batch normalization, and non-linear activation functions. The number of channels increases layer by layer to enhance feature abstraction capabilities. Through continuous convolution and pooling operations, spatial resolution is gradually compressed while extracting higher-dimensional semantic information. The encoder's key role is to establish a high-order semantic representation of the input image, enabling the model to understand the semantic position of the defect region within the overall texture, shape, and contextual structure. It also expresses complete spatial hierarchical relationships and cross-regional dependencies in the encoded features. This process captures local detail features and extracts global texture structure and directional consistency cues. The output is a multi-scale encoded feature map, with internal tensors containing feature layers ranging from coarse-grained to fine-grained. The encoded feature map is input into a direction-aware convolutional layer for texture orientation guidance processing. This layer dynamically adjusts the response of the convolutional kernel by incorporating the dominant orientation information from the fabric texture orientation feature matrix. This allows the kernel to select the most suitable receptive orientation based on the texture orientation corresponding to each pixel during convolution operations, thus achieving orientation adaptability in the convolution operation. Traditional convolutional kernels perform equal-weighted scanning in all directions, while the direction-aware convolution uses rotation or weighting to make its response stronger to the dominant orientation and weaker to non-dominant orientations. This mechanism enables the generative network to adaptively mimic the extension direction of the surrounding texture when filling defect areas, effectively avoiding problems such as incorrect texture orientation during repair, texture breakage during reconstruction, or rotation errors. After orientation-aware processing, the output is a direction-optimized encoded feature map. The oriented optimized encoded feature map is input into the decoder module in the coarse restoration generator for upsampling texture reconstruction. The decoder is symmetrical to the encoder structure and includes a transposed convolution (or upsampling + convolution) module to restore the spatial resolution of the feature map layer by layer. It outputs the final image structure by reducing the number of channels at each level. At the same time, a skip connection mechanism is introduced in each upsampling stage to concatenate or fuse the feature map in the corresponding encoding layer with the current decoding layer to achieve joint reconstruction of high-level semantic information and low-level detail features, and finally outputs the initial fabric restoration image.
[0035] In one example, the multi-scale encoded feature map is input into a direction-aware convolutional layer for texture orientation guidance processing, resulting in an orientation-optimized encoded feature map, including: Spatial position correspondence matching is performed between the multi-scale encoded feature map and the fabric texture orientation feature matrix to obtain an orientation guidance matrix of the same size as the multi-scale encoded feature map. The kernel parameters of the orientation-aware convolutional layer are dynamically adjusted based on the texture orientation angle information in the orientation guidance matrix. The kernel weights are rotated according to the orientation angle value of each pixel position to obtain a dynamic set of convolutional kernels. The multi-scale encoded feature map is subjected to pixel-wise adaptive convolution operation with a dynamic set of convolution kernels to obtain an orientation-aligned texture feature response map; The texture structure continuity enhancement process is applied to the orientation-aligned texture feature response map to obtain the orientation-optimized encoded feature map.
[0036] In this example, the multi-scale encoded feature map is spatially matched with the fabric texture orientation feature matrix. If the orientation feature matrix has a higher resolution than the encoded feature map, it is downsampled to match the size of the encoded feature map. Bilinear interpolation is used for image scaling to preserve the continuity and accuracy of orientation gradient changes as much as possible. After matching, an orientation guidance matrix of the same size as the multi-scale encoded feature map is constructed. Each pixel in this matrix records the numerical information of the dominant texture orientation angle at that location. The angle value is a real number in the range of 0 to 180 degrees, reflecting the main axis direction of the texture arrangement at that point. To apply this orientation information to the convolutional kernel operation, the standard convolutional kernel parameters are adjusted with orientation sensitivity, constructing a set of dynamic convolutional kernels with orientation adaptability. To this end, the system rearranges or geometrically rotates the standard convolutional kernel at a specific angle based on the angle value of each pixel in the orientation guidance matrix through interpolation rotation, generating a specific convolutional kernel for the current orientation. For example, if a standard 3×3 convolutional kernel is used to extract lateral texture features, when the dominant direction of the current pixel is 45°, the system rotates the standard convolutional kernel by 45° to ensure it has the same responsiveness in the new direction. This rotation is performed through bilinear interpolation or rotation matrix operations and is repeated at all pixel positions, resulting in a dynamic set of convolutional kernels with the same spatial size as the encoded feature map, where each pixel corresponds to an independent directional convolutional kernel. The dynamic set of convolutional kernels is then subjected to pixel-wise adaptive convolution with the multi-scale encoded feature map. That is, for each pixel position in the feature map, a convolutional kernel matching the texture direction at that position is selected for local convolution. Since the direction of the convolutional kernel at each position is different, the entire convolution operation exhibits high local adaptability, fully responding to the directional differences in texture arrangement in different regions, thereby generating an orientation-aligned texture feature response map. Texture structure continuity enhancement is performed on the orientation-aligned texture feature response map. This process includes two aspects: firstly, local structure-preserving filtering techniques (such as guided filtering and edge-preserving convolution) are used to preserve the details of the convolved image, eliminating response discontinuities caused by local orientation differences; secondly, a low-frequency compensation mechanism is introduced to perform fuzzy modeling and response compensation for directional discontinuities in the large-scale texture structure, thereby achieving a balance between high-frequency directional responses and low-frequency structural smoothness, improving the structural integrity and boundary smoothness of the final generated image. The output after continuity enhancement is the orientation-optimized encoded feature map.
[0037] In one example, the initial fabric restoration image is input into the second-stage fine restoration generator for wavelet multi-scale detail optimization and boundary fusion correction to obtain the target fabric restoration image, including: The initial fabric repair image, the defective fabric image, and the defect region localization mask are input into the three-branch fusion network of the second-stage fine repair generator to integrate multiple input features and obtain a fused input feature map. The fused input feature map is subjected to three-level wavelet decomposition to obtain a multi-scale wavelet feature representation. The multi-scale wavelet feature representation is input into the fine-grained inpainting generator network for detail optimization, resulting in a finely inpainted texture image. The original fabric region in the finely repaired texture image and the defective fabric image is fused and corrected to obtain the target fabric repair image.
[0038] In this example, the initial fabric repair image, the original defective fabric image, and the defect region localization mask are input into the three-branch fusion network of the second-stage fine repair generator. This network is designed with three input paths: the coarse repair result channel, the original image channel, and the mask image channel. After feature extraction by their respective feature encoders, these three are integrated into a unified fusion input feature map through cross-channel splicing or attention fusion. To enhance the multi-scale detail representation capability of the fusion feature map, the fusion input feature map is input into a wavelet decomposition module for three-level wavelet transform processing. Wavelet decomposition in image processing decomposes the image signal into different frequency components, thereby separating the structural layer from the detail layer. The Daubechies-4 wavelet basis is used to perform layer-by-layer decomposition on the fusion feature map. Each layer of wavelet decomposition divides the image into one low-frequency component and three high-frequency components, corresponding to the overall structural information of the image and the edge and texture details in the horizontal, vertical, and diagonal directions, respectively. The three-level decomposition yields four sets of high- and low-frequency image features at four scales, enabling the system to simultaneously focus on large-scale structural consistency and local micro-detail changes. The multi-scale wavelet feature maps are input into the feature optimization network of the fine-repair generator. This network employs a multi-branch convolutional architecture to process high- and low-frequency feature channels at different scales separately, and dynamically adjusts the importance of different scales through an attention weighting mechanism, enabling the network to select the optimal reconstruction scale based on the texture density and structural complexity of the target area. This module emphasizes context preservation and local consistency. During reconstruction, the network maintains the approximate structural shape of the coarse-repair result while filling in missing high-frequency details, such as fiber orientation, texture granularity, and the transition characteristics between boundary and background textures, thus outputting a fine-repair texture image with enhanced details and complete texture. Boundary fusion correction is performed on the fine-repair texture image and the original fabric region in the defective fabric image. Based on the defect region localization mask, the seam boundary between the repaired area and the original area is identified, and a progressive fusion strategy is applied within this boundary range to achieve pixel-level transition and style matching. The system establishes a buffer band in the mask edge region, and performs linear weighting, blur convolution or multi-scale fusion operations on the pixels of the repaired image and the original image within the buffer band to gradually reduce the differences between the repaired image and the original image in terms of color, texture intensity, structure frequency, etc. At the same time, an edge-preserving filter is used to enhance the edge continuity during the fusion process, and finally the target fabric repaired image is obtained.
[0039] In one example, the multi-scale wavelet feature representation is input into the fine-grained inpainting generator network for detail optimization, resulting in a fine-grained inpainted texture image, including: The multi-scale wavelet feature representation is input into the D residual blocks of the fine-grained repair generator network for concatenated feature extraction to obtain the deep residual feature representation. Add a self-attention layer between D residual blocks to perform spatial attention enhancement processing on the deep residual feature representation, and obtain an attention-enhanced texture feature map; The texture consistency constraint loss function is calculated based on the attention-enhanced texture feature map to obtain the comprehensive texture constraint loss value; Based on the comprehensive texture constraint loss value, the parameter weights of the fine-grained inpainting generator network are updated using the backpropagation algorithm, and the fine-grained inpainting generator network is used to generate a fine-grained texture image.
[0040] In this example, the deep feature extraction structure of the fine-grained inpainting generator, which inputs multi-scale wavelet feature representations into the core network, employs D concatenated residual blocks to form the backbone network structure. This backbone network performs multi-level feature modeling and residual information reconstruction. These residual blocks are based on a standard deep convolutional neural network design. Each residual block contains two consecutive convolutional layers, a batch normalization layer, and a ReLU activation function. A skip connection mechanism is used to add and fuse the block input and output, allowing the network to retain the expressive power of low-level features while performing nonlinear transformations. This alleviates the gradient vanishing problem in deep networks, improves training stability, and accelerates network convergence. After constructing concatenated paths between the D residual blocks, the system processes and refines the multi-scale wavelet features layer by layer, obtaining a feature representation tensor with deep semantics and residual information. A spatial self-attention mechanism is introduced between the D residual blocks. By constructing self-attention layers, the deep residual feature representation is enhanced, improving the model's ability to model texture structure dependencies across the entire image. This self-attention layer constructs an attention mapping matrix by calculating the similarity relationship between any two spatial locations. Based on this mapping result, it weights and aggregates all feature points to enhance key texture regions and suppress unimportant regions. The system performs linear mapping on the deep residual feature representation to generate three tensors: query (Q), key (K), and value (V). It then calculates the similarity score between Q and K through inner product operations. The score matrix is then normalized to form an attention weight distribution. This weight is used to weight and sum V to obtain the enhanced feature representation tensor, resulting in the attention-enhanced texture feature map. To ensure that the attention-enhanced texture feature map maintains consistency with the original image in terms of style, structure, and orientation, a set of texture consistency constraint loss functions is designed and calculated based on this feature map. This loss function integrates multiple sub-objectives such as perceptual loss, style loss, orientation consistency loss, and adversarial loss to comprehensively measure the deviation of the generated image in visual quality and semantic matching. The perceptual loss uses the output of the intermediate layers of the VGG network as perceptual features, and calculates the Euclidean distance in the feature space by comparing it with the perceptual features of the original image. Style loss measures the global statistical difference in texture styles within the image by constructing a Gram matrix. Orientation consistency loss extracts the gradient directions of textures in the image and calculates their deviations. Adversarial loss constructs the generator's optimization objective based on the discriminator's score of image realism in the generative adversarial network structure. These loss values are weighted and summed according to set weights to obtain a comprehensive texture constraint loss value, which quantifies the overall deviation level between the generated image and the ideal texture image. The system executes a backpropagation algorithm based on this comprehensive texture constraint loss value to update the gradient parameters of each level of the fine-grained inpainting generator. Adaptive learning rate mechanisms such as the Adam optimizer or RMSProp are used to stabilize the optimization process, and the weights of each module are adjusted after each iteration, thereby continuously improving the generator's inpainting capabilities in different image scenarios.After multiple rounds of iterative training and weight adjustment, a set of optimized fine-grained inpainting generator network parameters is finally formed. The system then feeds the input image into the updated fine-grained inpainting generator, and outputs a fine-grained texture image through the optimized structure extractor, self-attention enhancement module and loss-driven optimization path.
[0041] Reference Figure 2 This embodiment provides a fabric texture defect repair device based on generative adversarial networks, including: Decomposition module 1 is used to decompose the defective fabric image to be repaired to obtain the fabric texture direction feature matrix and the defect area localization mask. Processing module 2 is used to perform cross-domain feature unification processing on the fabric texture direction feature matrix through the gradient inversion layer to obtain unified feature encoding; Retrieval module 3 is used to perform similarity retrieval in the fabric texture semantic memory based on unified feature encoding to obtain the best matching texture reference feature; The structure reconstruction module 4 is used to input the defect area localization mask and the defect fabric image into the first-stage coarse repair generator for structure reconstruction based on the best matching texture reference features, so as to obtain the initial fabric repair image. The detail optimization module 5 is used to input the initial fabric repair image into the second-stage fine repair generator for wavelet multi-scale detail optimization and boundary fusion correction to obtain the target fabric repair image.
[0042] In this embodiment, the specific implementation of each unit in the above device embodiment is described in the above method embodiment, and will not be repeated here.
[0043] This invention employs a domain obfuscation mechanism, built upon a gradient inversion layer and a texture domain classifier, to effectively eliminate domain differences between different texture types. This forces the generator to learn domain-invariant texture feature representations, thus maintaining stable repair performance across various fabric types such as cotton, silk, and wool. A two-stage progressive repair architecture is adopted: the first-stage coarse repair generator focuses on reconstructing the texture structure skeleton, while the second-stage fine repair generator optimizes details. This hierarchical processing mechanism effectively solves the structural discontinuities and detail loss problems that often occur in traditional single-stage methods when repairing large-area defects. The establishment of a fabric texture semantic memory enables effective storage and transfer of cross-domain texture knowledge. Through cosine similarity matching and attention-weighted fusion mechanisms, the most relevant texture reference features are provided for the current repair task, avoiding the shortcomings of traditional methods that lack prior texture knowledge accumulation. The orientation-aware convolutional layer dynamically adjusts the convolution kernel parameters and achieves orientation-adaptive feature extraction based on the fabric texture orientation feature matrix, ensuring that the texture orientation of the repaired area remains consistent with the surrounding area. This effectively solves the problem of unnatural repair caused by traditional methods ignoring texture orientation. The wavelet transform-based multi-scale texture reconstruction strategy can simultaneously handle the overall structure and detailed features of textures. Through the fusion of three-level wavelet decomposition and an attention mechanism, it achieves layer-by-layer texture reconstruction from coarse to fine, ensuring consistent quality across different scales. The boundary fusion correction mechanism implemented using a Gaussian filter effectively eliminates visual abrupt changes between the repaired and original regions, achieving a seamless and natural transition, avoiding the problem of obvious repair boundaries in traditional methods. The two-stage architecture allows for the rational allocation of computational resources according to the complexity of the repair task: the coarse repair stage rapidly reconstructs the basic structure, while the fine repair stage focuses on detail optimization, ensuring both repair quality and computational efficiency.
[0044] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.
[0045] The above description is merely a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for repairing fabric texture defects based on generative adversarial networks, characterized in that, include: The defective fabric image to be repaired is decomposed to obtain the fabric texture direction feature matrix and the defect area localization mask. The fabric texture direction feature matrix is subjected to cross-domain feature unification processing through a gradient inversion layer to obtain a unified feature code. Based on the unified feature encoding, a similarity search is performed in the fabric texture semantic memory to obtain the best matching texture reference feature; Based on the best matching texture reference features, the defect region location mask and the defect fabric image are input into the first-stage coarse repair generator for structural reconstruction to obtain the initial fabric repair image. The initial fabric restoration image is input into the second-stage fine restoration generator for wavelet multi-scale detail optimization and boundary fusion correction to obtain the target fabric restoration image.
2. The fabric texture defect repair method based on generative adversarial networks according to claim 1, characterized in that, The defective fabric image to be repaired is decomposed to obtain the fabric texture direction feature matrix and the defect region localization mask, including: The defective fabric image to be repaired is sized and standardized to obtain a standard fabric image. The standard fabric image is then enhanced in contrast by histogram equalization to obtain a preprocessed standard fabric image. The preprocessed standard fabric image is input into a Gabor filter bank for multi-directional texture feature decomposition to obtain the filter response amplitude matrix. The dominant texture direction and intensity information of each pixel are calculated based on the filter response amplitude matrix, and a fabric texture direction feature matrix is constructed based on the dominant texture direction and intensity information. The preprocessed standard fabric image is input into the DeepLabV3+ semantic segmentation network for pixel-level defect detection to obtain the defect region localization mask.
3. The fabric texture defect repair method based on generative adversarial networks according to claim 2, characterized in that, The step of inputting the preprocessed standard fabric image into the DeepLabV3+ semantic segmentation network for pixel-level defect detection to obtain a defect region localization mask includes: The preprocessed standard fabric image is input into the ResNet backbone network in the DeepLabV3+ semantic segmentation network for multi-level feature extraction to obtain the fabric texture feature map. The fabric texture feature map is input into the void space pyramid pooling module for multi-scale contextual information fusion to obtain an enhanced feature map. The enhanced feature map is input into the decoder for resolution restoration processing to obtain a full-resolution semantic feature map, and the full-resolution semantic feature map is subjected to pixel-level binary classification processing to obtain a pixel-level defect probability distribution map. The pixel-level defect probability distribution map is binarized to obtain the defect area location mask that identifies the defect area.
4. The fabric texture defect repair method based on generative adversarial networks according to claim 1, characterized in that, The process of performing cross-domain feature unification processing on the fabric texture direction feature matrix through a gradient inversion layer to obtain unified feature encoding includes: The fabric texture direction feature matrix is input into the gradient inversion layer for feature transfer, resulting in the transferred texture feature matrix. The transmitted texture feature matrix is input into a texture domain classifier for domain category recognition processing to obtain a domain classification probability vector. The domain confusion loss is calculated based on the domain classification probability vector, and the gradient is reversed during backpropagation based on the domain confusion loss to obtain a unified feature code.
5. The fabric texture defect repair method based on generative adversarial networks according to claim 1, characterized in that, The step of performing a similarity search in the fabric texture semantic memory based on the unified feature encoding to obtain the best matching texture reference features includes: The cosine similarity between the unified feature code and the N texture domain feature prototypes stored in the fabric texture semantic memory is calculated to obtain the similarity numerical matrix between the unified feature code and each texture domain feature prototype. Based on the similarity numerical matrix, a candidate texture feature prototype set is obtained by sorting and filtering in descending order. Calculate the attention weight coefficient for each texture domain feature prototype in the candidate texture feature prototype set to obtain the attention weight vector; The candidate texture feature prototype set is weighted and fused according to the attention weight vector to obtain the best matching texture reference feature that fuses the texture features of the current defective fabric.
6. The fabric texture defect repair method based on generative adversarial networks according to claim 1, characterized in that, Based on the optimal matching texture reference features, the defect region localization mask and the defective fabric image are input into the first-stage coarse repair generator for structural reconstruction to obtain an initial fabric repair image, including: The best matching texture reference feature, the defect region localization mask and the defective fabric image are spliced and fused along the channel dimension to obtain a multi-channel input feature map. The multi-channel input feature map is input into the encoder of the first-stage coarse repair generator for downsampling feature extraction to obtain a multi-scale encoded feature map. The multi-scale encoded feature map is input into a direction-aware convolutional layer for texture direction guidance processing to obtain a direction-optimized encoded feature map. The optimized coded feature map is input into the decoder for upsampling texture reconstruction to obtain the initial fabric repair image.
7. The fabric texture defect repair method based on generative adversarial networks according to claim 6, characterized in that, The step of inputting the multi-scale encoded feature map into a direction-aware convolutional layer for texture direction guidance processing to obtain a direction-optimized encoded feature map includes: The multi-scale encoded feature map is spatially matched with the fabric texture direction feature matrix to obtain a direction guidance matrix of the same size as the multi-scale encoded feature map. Based on the texture direction angle information in the direction guidance matrix, the convolution kernel parameters of the direction-aware convolutional layer are dynamically adjusted, and the corresponding convolution kernel weights are rotated according to the direction angle value of each pixel position to obtain a dynamic convolution kernel set. The multi-scale encoded feature map is subjected to pixel-wise adaptive convolution operation with the dynamic convolution kernel set to obtain an orientation-aligned texture feature response map; The texture feature response map with the alignment is subjected to texture structure continuity enhancement processing to obtain the orientation-optimized encoded feature map.
8. The fabric texture defect repair method based on generative adversarial networks according to claim 1, characterized in that, The process of inputting the initial fabric restoration image into the second-stage fine restoration generator for wavelet multi-scale detail optimization and boundary fusion correction to obtain the target fabric restoration image includes: The initial fabric repair image, the defective fabric image, and the defective region localization mask are input into the three-branch fusion network of the second-stage fine repair generator to integrate multiple input features and obtain a fused input feature map. The fused input feature map is subjected to three-level wavelet decomposition to obtain a multi-scale wavelet feature representation; The multi-scale wavelet feature representation is input into the fine-grained inpainting generator network for detail optimization to obtain a finely inpainted texture image. The boundary fusion correction is performed on the original fabric region in the finely repaired texture image and the defective fabric image to obtain the target fabric repair image.
9. The fabric texture defect repair method based on generative adversarial networks according to claim 8, characterized in that, The step of inputting the multi-scale wavelet feature representation into the fine-grained inpainting generator network for detail optimization to obtain a fine-grained inpainted texture image includes: The multi-scale wavelet feature representation is input into the D residual blocks of the fine repair generator network for concatenated feature extraction to obtain the deep residual feature representation. A self-attention layer is added between the D residual blocks to perform spatial attention enhancement processing on the deep residual feature representation, resulting in an attention-enhanced texture feature map; The texture consistency constraint loss function is calculated based on the attention-enhanced texture feature map to obtain the comprehensive texture constraint loss value; Based on the comprehensive texture constraint loss value, the parameter weights of the fine-grained inpainting generator network are updated using the backpropagation algorithm, and the fine-grained inpainting generator network is used to generate a fine-grained inpainting texture image.
10. A fabric texture defect repair device based on generative adversarial networks, characterized in that, The fabric texture defect repair device based on generative adversarial networks (GANs) is used to implement the steps of the fabric texture defect repair method based on GANs according to any one of claims 1 to 9, wherein the fabric texture defect repair device based on GANs comprises: The decomposition module is used to decompose the defective fabric image to be repaired, and obtain the fabric texture direction feature matrix and the defect area localization mask. The processing module is used to perform cross-domain feature unification processing on the fabric texture direction feature matrix through a gradient inversion layer to obtain a unified feature code. The retrieval module is used to perform similarity retrieval in the fabric texture semantic memory based on the unified feature encoding to obtain the best matching texture reference feature; The structure reconstruction module is used to input the defect region positioning mask and the defect fabric image into the first-stage coarse repair generator based on the best matching texture reference features to perform structure reconstruction and obtain the initial fabric repair image. The detail optimization module is used to input the initial fabric repair image into the second-stage fine repair generator for wavelet multi-scale detail optimization and boundary fusion correction to obtain the target fabric repair image.
Citation Information
Cited By
Machining surface defect detection method and system based on bidirectional feature fusion
CN121544609A
Method and system for detecting surface defects of machined workpiece based on bidirectional feature fusion
CN121544609B