Fabric defect detection method
By combining spatial and frequency domain features with a multi-input network structure, and utilizing the ViT-S model and TPP module for fabric texture detection, the accuracy problem of existing methods in complex environments is solved, and robust detection is achieved under conditions such as noise, jitter, and additive residues.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-04
- Publication Date
- 2026-03-10
AI Technical Summary
Existing image processing-based fabric texture detection methods are easily affected by noise, vibration, and other interferences in actual production environments, leading to reduced detection accuracy and reliability, especially issues such as auxiliary agent residues and yarn swelling.
A multi-input network structure is adopted, which combines spatial and frequency domain image features. The fabric texture information is extracted through the ViT-S model, and the TPP module is used for multi-grid complementarity. The FiLM module is used for feature fusion, and the final result is output through a classifier.
It effectively overcomes the accuracy problem of detecting complex fabric textures and improves the classification stability and accuracy under complex working conditions such as noise, vibration and auxiliary agent residue.
Smart Images

Figure CN121639684A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of fabric texture detection technology, and more particularly to a method for detecting defects in fabrics. Background Technology
[0002] Fabric texture detection is a crucial step in quality control within the textile industry, directly impacting product quality and yield. Existing image processing-based fabric texture detection methods have limitations in real-world production environments, particularly being susceptible to interference from noise and vibration. Furthermore, the addition of auxiliaries during fabric setting or finishing processes can lead to issues such as yarn swelling and the formation of patchy spots. These factors significantly affect image clarity and stability, thereby reducing the accuracy and reliability of fabric texture detection.
[0003] To visually illustrate the impact of different working conditions on the accuracy of fabric texture detection, three types of samples are presented below: Figure 3 The sample was taken from dry fabric under stable lighting conditions. The warp and weft yarn boundaries are clear, the contrast is high, and the stripe spacing is generally uniform. Figure 4 These are residual auxiliaries on plain weave fabrics, resulting from the presence of localized, blocky spots and yarn swelling caused by residual auxiliaries or sizing agents after setting or finishing processes. This type of low-frequency, large-area interference can cause localized bright or dark spots. Figure 5 The jitter or slight motion blur of the plain pattern is caused by slight vibration of the equipment or slight displacement of the camera during the acquisition stage, resulting in directional motion blur and detail blur. Summary of the Invention
[0004] To address the shortcomings of existing methods, this invention combines features from spatial and frequency domain images and extracts rich texture information from fabrics through a multi-input network structure, thereby effectively overcoming the problem that the accuracy of traditional methods in detecting complex fabric textures needs further improvement.
[0005] The technical solution adopted in this invention is: a method for detecting defects in fabrics, comprising the following steps: Step 1: Collect images of fabrics with different textures; In a preferred embodiment of the present invention, the fabric image includes: a normal image and an abnormal image; the abnormal image includes: an image of residual auxiliary spot defects, a shaking image, and a motion blur image.
[0006] As a preferred embodiment of the present invention, the texture categories of the fabric include: plain weave, twill weave, rib weave, double-sided weave, ribbed weave, high-density weave, and jacquard weave.
[0007] Step 2: Input the spatial domain map into any layer from layer 1 to layer 6, layer 7 to layer 10, and layer 11 to layer 12 of the spatial domain encoder of the ViT-S model, and output the spatial domain first layer block vector, spatial domain second layer block vector, and spatial domain third layer block vector. Input the frequency domain diagram into any one of the layers 1 to 6, any one of the layers 7 to 10, and any one of the layers 11 to 12 of the frequency domain encoder of the ViT-S model, and output the first block vector of the frequency domain, the second block vector of the frequency domain, and the third block vector of the frequency domain. Input the first layer block vector, the second layer block vector, and the third layer block vector into the TPP module to obtain the first fixed-length vector, the second fixed-length vector, and the third fixed-length vector. Input the first block vector, the second block vector, and the third block vector in the frequency domain into the TPP module to obtain the first fixed-length vector, the second fixed-length vector, and the third fixed-length vector in the frequency domain. After the first fixed-length vector in the frequency domain is input into the MLP layer, it is input together with the first fixed-length vector in the spatial domain into the FiLM module to obtain the fused first-layer features. After the second fixed-length vector in the frequency domain is input into the MLP layer, it is input together with the second fixed-length vector in the spatial domain into the FiLM module to obtain the fused second-layer features. The first layer features, the second layer features, the spatial domain third layer block vector, and the frequency domain first layer block vector, the frequency domain second layer block vector, and the frequency domain third layer block vector are concatted and then input into the classifier to output the classification result.
[0008] As a preferred embodiment of the present invention, the models of the spatial domain encoder and the frequency domain encoder of the block vector further include: a CNN model.
[0009] In a preferred embodiment of the present invention, the classifier includes: LayerNorm, a first fully connected layer, a second fully connected layer and a Softmax layer connected in sequence.
[0010] In a preferred embodiment of the present invention, the first layer block vector is the 6th layer, the second layer block vector is the 10th layer, and the third layer block vector is the 12th layer.
[0011] The beneficial effects of this invention are: This invention selects to extract shallow, medium and deep layers of spatial and frequency domain ClsTokens, effectively covering detailed textures, mesoscale repeating units and global structure; and combines multi-grid pooling to classify fabrics under complex working conditions such as noise, shaking and auxiliary agent residue. Utilize TPP to perform multi-grid complementarity on tokens or convolutional blocks; cover the frequency or spatial range from local to mesoscale to global through three levels × three grids; 3. The FiLM fusion layer selection of 6 and 10 can cover two key texture scales; it can also cover latitude and longitude repeating or strip robust textures; the two complement each other to cover the main texture. Attached Figure Description
[0012] Figure 1 This is the first defect detection model for fabrics according to the present invention; Figure 2 This is the second defect detection model for fabrics according to the present invention; Figure 3 It is a plain weave fabric pattern; Figure 4 It is a pattern of residual additives on a plain weave. Figure 5 It is a jitter or slight motion blur image of a plain pattern. Detailed Implementation
[0013] The present invention will be further described below with reference to the accompanying drawings and embodiments. The drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.
[0014] A method for detecting defects in a fabric includes the following steps: Step 1: Collect images of fabrics with different textures; Images of fabrics with different yarn thicknesses, weft densities, and weaving methods were captured using an industrial camera under stable lighting conditions, in RGB format. Fabric images include: normal images and abnormal images; Among them, abnormal images include: defect images of residual additive spots, jitter images, and motion blur images; The collected images are organized into a dataset, and each image is classified and labeled according to the fabric texture category to ensure that each image can generate two inputs in the spatial domain and frequency domain in a one-to-one correspondence. The fabric texture categories are coded as follows: plain weave is 0, twill is 1, rib is 2, double-sided is 3, ribbed is 4, high density is 5, and jacquard is 6.
[0015] The dataset was divided into training, validation, and testing components in a ratio of 8:1:1. The fabric images are preprocessed and subjected to Fourier transform. The preprocessing includes applying Gaussian filtering to each image to remove noise and interference and improve image quality.
[0016] The fabric image undergoes frequency domain transformation, which includes: Fourier transform: First, take the brightness component Y = 0.299R + 0.587G + 0.114B of the filtered image, where R, G, and B are red, green, and blue, respectively; then apply a two-dimensional Hann window; subsequently, perform a two-dimensional Fourier transform, such as OpenCV's cv::dft; and perform spectrum centering to obtain the complex spectrum F. Spectrum calculation: Construct a three-channel frequency domain graph and normalize it. Channel 1 is the amplitude: log(1+|F|), where || is the absolute value; first perform 0.1%~99.8% percentile clipping, then normalize to [0,1] using log1p and min-max; Channel 2 is the phase cosine: (1+cos∠F) / 2; Channel 3 is the phase sine: (1+sin∠F) / 2.
[0017] The spatial domain map is a sub-map of the fabric image, which is divided into sub-maps of size 3×224×224; if the original size of the fabric image is 3×224×224, then no division is required.
[0018] Both the frequency domain and spatial domain images are uniformly cropped to 224×224, copied to 3 channels, and standardized according to ImageNet mean and variance, thus serving as the network input tensors: spatial domain image X_t, frequency domain image X_f∈ [3×224×224], It is the set of real numbers.
[0019] Step 2: Input the spatial domain map into any layer from layer 1 to layer 6, layer 7 to layer 10, and layer 11 to layer 12 of the spatial domain encoder of the ViT-S model, and output the spatial domain first layer block vector, spatial domain second layer block vector, and spatial domain third layer block vector. Input the frequency domain diagram into any one of the layers 1 to 6, any one of the layers 7 to 10, and any one of the layers 11 to 12 of the frequency domain encoder of the ViT-S model, and output the first block vector of the frequency domain, the second block vector of the frequency domain, and the third block vector of the frequency domain. Input the first layer block vector, the second layer block vector, and the third layer block vector into the TPP module to obtain the first fixed-length vector, the second fixed-length vector, and the third fixed-length vector. Input the first block vector, the second block vector, and the third block vector in the frequency domain into the TPP module to obtain the first fixed-length vector, the second fixed-length vector, and the third fixed-length vector in the frequency domain. After the first fixed-length vector in the frequency domain is input into the MLP layer, it is input together with the first fixed-length vector in the spatial domain into the FiLM module to obtain the fused first-layer features. After the second fixed-length vector in the frequency domain is input into the MLP layer, it is input together with the second fixed-length vector in the spatial domain into the FiLM module to obtain the fused second-layer features. The first layer features, the second layer features, the spatial domain third layer block vector, and the frequency domain first layer block vector, the frequency domain second layer block vector, and the frequency domain third layer block vector are concatted and then input into the classifier to output the classification result. The first implementation method uses the spatial encoder and frequency encoder in the ViT-S model; Spatial domain encoders and frequency domain encoders are essentially feature extraction backbone networks; A visual Transformer model with dual-input feature fusion is constructed, using a dual-tower DINOv2 ViT-S14 with 14 patches, 384 hidden dimensions, and 12 layers, with no shared weights. Convert X_f into a frequency domain shape vector F_Stem: X_f is fed into the ViT-S14 frequency domain encoder PatchEmbedding; where patch=14, stride=14; resulting in Nt=16×16=256 image patches, dimension D=384; add absolute position encoding to obtain F_Stem∈ ^{B×256×384}, where B is the batch size; F_Stem is converted into frequency domain block vectors F_Blocks for output of each layer of the frequency domain backbone. Through 12 Transformer Blocks, the tokens after each layer are denoted as F_Blocks={Tokens_f_L1,…,Tokens_f_L12}, and the shape of each token is B×256×384. In this embodiment, the first frequency domain block vector is Tokens_f_Li, the second frequency domain block vector is Tokens_f_Lj, and the third frequency domain block vector is Tokens_f_Lk. The three frequency domain block sub-vectors are used to form a frequency domain fixed-length vector.
[0020] Convert X_t into a spatial shape vector T_Stem: X_t is fed into the ViT-S14 spatial encoder PatchEmbedding; where patch=14, stride=14; resulting in Nt=16×16=256 image patches, dimension D=384; add absolute position encoding to obtain T_Stem∈ ^{B×256×384}; T_Stem is converted into spatial block vectors T_Blocks for outputting each layer of the spatial backbone. Twelve Transformer Blocks are used, and the tokens following each layer are denoted as T_Blocks={Tokens_t_L1,…,Tokens_t_L12}, with each token having a shape of B×256×384. In this embodiment, the first spatial layer block vector is Tokens_t_Li, the second spatial layer block vector is Tokens_t_Lj, and the third spatial layer block vector is Tokens_t_Lk. These three spatial block sub-vectors are used to form a fixed-length spatial vector. In this embodiment, i=6, j=10, k=12; In this context, the first layer block vector is considered a shallow layer, the second layer block vector is considered a middle layer, and the third layer block vector is considered a deep layer.
[0021] Feature fusion: Three spatial domain block vectors and three frequency domain block vectors are input into a multi-scale convergence module, which uses TPP (Token-Pyramid Pooling). Alternatively, pyramid pooling, adaptive pooling, SPP, ASPP, and attention pooling can be used to form corresponding fixed-length spatial and frequency domain vectors. Specifically, the tokens at each tap are restored to 384×16×16, and adaptive average pooling is performed on 1×1, 2×2, and 4×4 grids. After linear compression to 128 dimensions at each scale, the vectors are concatenated along the channel dimension to obtain a fixed-length 384-dimensional vector (128×3=384). The output frequency domain fixed-length vectors are TPP_f3, TPP_f4, and TPP_f5, and the spatial domain fixed-length vectors are TPP_t3, TPP_t4, and TPP_t5, all of which are 384-dimensional. Among them, TPP_f3, after undergoing feature transformation, is combined with TPP_t3 through the feature fusion module to generate the first layer feature t3_prime; After TPP_f4 undergoes feature transformation, it is combined with TPP_t4 through the feature fusion module to generate the first layer feature t4_prime.
[0022] The feature transformation module uses an MLP layer; alternatively, linear layers, 1×1 convolutional layers, gating, and small attention can also be used. The feature fusion module uses FiLM.
[0023] The shallow and medium-level features in the frequency and spatial domains are conditionally modulated by scaling and translating dimensionally using the FiLM module. The six vectors are then concatenated and the seven probabilities are output through the classification head.
[0024] Specifically: TPP_f3 and TPP_f4 are each passed through an MLP layer with the same structure to generate the dimension-wise scaling and translation parameters γ,β∈ ^{384}, and perform linear modulation on the feature dimensions of TPP_t3 and TPP_t4, and fuse the features of the m-th layer tm_prime as follows: tm_prime=σ(γ)⊙LN(t)+β; Where σ(.) is the Sigmoid function; m = 3, 4; LN(.) is LayerNorm; ⊙ represents dimension-wise multiplication; t ∈ ^384 is the spatial TPP vector of the corresponding layer.
[0025] The present invention preferably performs FiLM conditionalization at two locations: the 6th layer L6 and the 10th layer L10 of Tokens; thus obtaining conditional features FiLM_L6 and FiLM_L10. L6 enhances yarn details or short-period textures, while L10 enhances warp and weft repetition or stripes. The 12th layer L12 of Tokens is not FiLM conditionalized to avoid interfering with the final global discrimination. In addition, L12 carries global aggregation and category boundaries, keeping TPP_f5 and TPP_t5 unmodulated, which can avoid excessive "correction" that destroys the learned global discriminability, while also saving computation.
[0026] Same-scale semantic alignment: L6 and L10 correspond to fine texture and mesoscale repeating units, respectively; TPP_f3 and TPP_f4 are matched with TPP_t3 and TPP_t4 in terms of representation scale to avoid "cross-layer and cross-scale" mismatch; Noise suppression and robustness: Frequency domain amplitude or phase is more stable against jitter, slight blur, and illuminance changes; using σ(γ) as a dimension-wise gate can suppress the dimension affected by noise in the spatial domain and amplify the dimension related to the yarn period; fewer samples make it easier to converge: FiLM is a conditional affine, with far fewer parameters than splicing + MLP, reducing the risk of overfitting; dual inputs significantly improve minority classes such as classes 5 and 6 in the experiment. We obtain t3_prime and t4_prime; both have a dimension of 384, corresponding to L6 and L10 of the feature extraction backbone network. At L6, firstly, it can cover two key texture scales, namely, it is most sensitive to yarn details or short cycles; at L10, it is robust to warp and weft repetition or stripes. The two complement each other to cover the main texture causes. Secondly, FiLM can bring significant benefits in only two places. Furthermore, the modulation benefits at L12 are limited, and it is easy to interfere with the final discrimination layer, which is a trade-off between computation and stability.
[0027] TPP_t5, TPP_f3, TPP_f4, and TPP_f5 are retained; then concatenated with t3_prime and t4_prime; each of the six vectors is 384-dimensional, and after concatenation, a 2304-dimensional feature is obtained; then, it is passed through LayerNorm, the first fully connected layer (2304→512, GELU, Dropout) and the second fully connected layer (512→7) in sequence to output seven classes of logits, and the classification probability is obtained by Softmax.
[0028] This invention selects L6, L10, and L12 layers for token extraction because these three layers respectively cover detailed texture, mesoscale repeating units, and global structure. Combining multi-grid pooling provides more robust classification of fabrics under complex conditions such as noise, vibration, and auxiliary agent residue. First, it matches the fabric texture level, which simultaneously includes: microscopic yarn patterns, such as short-range cycles or details; mesoscale warp and weft interlacing blocks, such as repeating units or stripes; and global arrangement and defect interference, such as long-range dependencies. Second, the L6 layer retains more local edge or periodic textures, which is beneficial for identifying fine-grained patterns such as ribs and weaves. Third, the L10 layer has both texture and semantic mesoscale representation, which more robustly covers repeating units caused by different weft densities or weaving. Fourth, the L12 layer aggregates global information and long-range dependencies, which has stronger robustness to background interference such as vibration and auxiliary agent residue.
[0029] Tokens complement TPP's multi-grid design; three levels × three grids together cover the frequency or spatial range from local to mesoscale to global; among them, 1×1: global statistical jitter and exposure offset robustness; 2×2: mesoscale blocks or stripes; 4×4: detail textures or short periods.
[0030] like Figure 2 The second implementation method uses the spatial domain encoder and frequency domain encoder in the CNN model. Spatial domain encoders and frequency domain encoders can also use the Hybrid-ViT model.
[0031] The CNN model still uses a dual-input, dual-branch structure to extract features from the spatial domain image and the frequency domain image respectively; Specifically, it includes: 1. Spatial Domain Feature Extraction Branch: X_t is input into the first feature extraction branch, which is a CNN model used to perform layer-by-layer convolutional encoding on the input image to extract multi-level spatial texture features. The CNN model includes three consecutive feature extraction stages, Stage 1 to Stage 3, each consisting of a convolutional layer, a normalization layer, and a non-linear activation layer.
[0032] The structure of each stage is set as follows: Stage 1 consists of two convolutional layers connected in series; the first convolutional layer has a kernel size of 3×3, a stride of 2, and 64 output channels; the second convolutional layer has a kernel size of 3×3, a stride of 1, and 64 output channels. Stage 2 consists of two convolutional layers connected in series; the first convolutional layer has a kernel size of 3×3, a stride of 2, and 128 output channels; the second convolutional layer has a kernel size of 3×3, a stride of 1, and 128 output channels. Stage 3 consists of two convolutional layers connected in series; the first convolutional layer has a kernel size of 3×3, a stride of 2, and 256 output channels; the second convolutional layer has a kernel size of 3×3, a stride of 1, and 256 output channels. Each convolutional layer is followed by a normalization layer and a non-linear activation layer, where the normalization layer is BatchNormalization and the non-linear activation layer is ReLU, which are used to improve the stability of network training and non-linear expressive power.
[0033] From the feature extraction stages at different depths, the first spatial layer block vector is output, defined as Feat_t_S1; the second spatial layer block vector is defined as Feat_t_S2; and the third spatial layer block vector is defined as Feat_t_S3.
[0034] The shallow, medium, and deep features correspond to the local detail information, medium-scale repeating structure information, and global texture distribution information of the fabric texture, respectively.
[0035] Frequency domain feature extraction branch: X_f is input into the second feature extraction branch, whose structure is the same or similar to that of the spatial domain branch. It also uses a CNN model for multi-layer feature encoding. From different feature extraction stages, the following are output: the first layer block vector in the frequency domain, defined as Feat_f_S1; the second layer block vector in the frequency domain, defined as Feat_f_S2; and the third layer block vector in the frequency domain, defined as Feat_f_S3.
[0036] Frequency domain features mainly characterize the periodicity, directionality, and frequency distribution of fabric images, and are highly robust to interferences such as shaking, blurring, and additive residues.
[0037] The multi-scale feature aggregation and fusion method is the same as that in the first implementation method, namely: Input Feat_t_S1, Feat_t_S2, and Feat_t_S3 into the TPP module to obtain the corresponding TPP_t3, TPP_t4, and TPP_t5. Input Feature_f_S1, Feature_f_S2, and Feature_f_S3 into the TPP module to obtain TPP_f3, TPP_f4, and TPP_f5 respectively. At the shallow and middle layer features, FiLM is used for cross-domain fusion. TPP_f3 is linearly modulated in the MLP layer feature dimension, and then FiLM conditionalized with TPP_t3, with FiLM_S1 as the conditional feature, to obtain the first fused feature as t3_prime. TPP_f4 is linearly modulated in the MLP layer feature dimension, and then FiLM conditionalized with TPP_t4, with FiLM_S2 as the conditional feature, to obtain the second fused feature as t4_prime.
[0038] Feature concatenation and classification: The six vectors are concatenated and the seven class probabilities are output through the classification head.
[0039] ViT-S model training process: The algorithm employs cross-entropy loss and the AdamW optimizer, first using a linear probe to freeze the backbone and train only the head and fusion layers; then, it unfreezes the last block of the backbone at a low learning rate for fine-tuning, in two stages: Linear probe stage: Freeze the two tower backbones, such as PatchEmbed, 12×Blocks, positional encoding, etc.; train only the learnable part of TPP, such as implementing a two-layer MLP with 1×1 convolutional layer or linear layer, FiLM, to generate γ, β, and the spliced LayerNorm maintains learnable affine, and the classification head is fully connected + GELU + Dropout.
[0040] Slight Unfreezing Phase: Unfreeze the last block of the backbone, Tokens_f_L12 and Tokens_t_L12; fine-tune for 30 epochs with a small learning rate of 3e-4; train TPP, FiLM, and classification head with the same settings as the linear probe phase, i.e., except for the unfreezing range and learning rate, other hyperparameters are the same as in the linear probe phase, such as the optimizer AdamW, loss as cross-entropy, and early stopping patience value of 10 epochs; use metrics such as Accuracy and Macro-F1 for verification and evaluation, and stop early if there is no improvement after 10 consecutive epochs; The trained model is used to classify and identify newly acquired fabric images; New image preprocessing: Perform filtering, size alignment, normalization, Fourier transform, and spectral normalization on newly acquired images consistent with training. Model inference: The spatial and frequency domain inputs are fed into the forward inference of the trained model to obtain the probability distributions of the seven classes; Texture category recognition: Determine the texture category 0-6 based on the highest probability.
[0041] ViT-S model ablation experiment: Experimental objective: To verify the classification performance and adaptability to complex working conditions of three schemes: single-path spatial domain feature, single-path frequency domain feature, and spatial-frequency domain dual-input fusion, on seven types of fabric textures. Single spatial domain: DINOv2 ViT-S14 single tower, spatial domain 3×224×224 as input, CLS or GAP+ linear head classification; Single frequency domain: The structure is the same as above, but only the three-channel spectrum in the frequency domain is used as input; Dual input in spatial and frequency domains: dual-tower ViT-S14; tokens are extracted in shallow, medium and deep layers and converged through TPP multi-scale; the frequency domain vector is used to perform dimensional scaling and translation conditionalization on the spatial domain vector through FiLM, and then concatenated and sent into the linear classification head.
[0042] Training process: The first stage is a linear probe, freezing the two main trunks (PatchEmbed, 12×Blocks, positional encoding, etc.), and training only the fusion layer and classification head; the optimizer used is AdamW, with a learning rate LR=3×10. -3 The training was conducted for 80 epochs, with the loss function being cross-entropy loss.
[0043] The second stage involves fine-tuning, unfreezing only the last block of the backbone (Block 12), while keeping the rest frozen; a small learning rate LR=3×10 is set for the unfrozen layers. -4 For the trained fusion layer and classification head, maintain LR=3×10. -3 This phase of training consists of 30 epochs.
[0044] The evaluation metrics used are precision, recall, and F1 score. The evaluation metrics for different textures are shown in Table 1.
[0045] Table 1 Comparison of experimental results for the three schemes
[0046] Experimental results show that the dual-input ViT-S14+TPP+FiLM in both spatial and frequency domains achieves the best overall performance. Its average precision, recall, and F1 are significantly better than those of the single spatial domain and far exceed those of the single frequency domain. From a class-by-class perspective, the dual input brings significant improvements in classes that are more sensitive to interference, such as Class-4 or Class-5, while also improving the stability of Class-0, Class-3, or Class-6.
[0047] This invention improves the classification accuracy of seven types of fabric textures without significantly increasing the number of parameters by using dual inputs of amplitude or phase in both the spatial and frequency domains, combined with a visual Transformer backbone, Token-Pyramid Pooling, and FiLM conditional modulation. The frequency domain provides periodic and directional priors, the spatial domain preserves local texture details, and FiLM provides lightweight and stable cross-modal guidance in the middle layer. The uniform 224×224 size and ImageNet standardization facilitate engineering reproduction and deployment. Even in complex production environments, such as those with noise, slight jitter, and changes in lighting, this invention maintains stable recognition performance, meeting the application requirements of online quality inspection and sorting.
[0048] CNN model training process: The first stage freezes the convolutional backbone network, training only the multi-scale convergence module, feature transformation module, feature fusion module, and classification head. The second stage unfreezes the convolutional backbone network. The third stage performs fine-tuning, and a smaller learning rate is used for the unfrozen part to improve generalization performance under complex conditions.
[0049] CNN model ablation experiment: While keeping the feature fusion structure unchanged, the feature extraction backbone network was replaced by a CNN network instead of a visual Transformer. Spatial single-input model, frequency single-input model and spatial-frequency dual-input fusion model based on convolutional neural network were constructed, and comparative experiments were conducted under the same dataset and training strategy.
[0050] Experimental results show that when using a CNN network as the backbone network, the spatial domain single-input model can extract local texture features of fabrics, but its recognition stability and accuracy are affected to some extent under complex conditions such as residual spots of auxiliaries, shaking and slight motion blur. The frequency domain single-input model has certain advantages in periodic and directional texture recognition, but its ability to distinguish spatial details is limited.
[0051] In comparison, the convolutional neural network model with a spatial-frequency dual-input fusion structure is significantly better than the two single-input models mentioned above in terms of overall recognition performance. In particular, it shows higher robustness and consistency in fabric texture categories that are more susceptible to noise interference. The results for different textures are shown in Table 2.
[0052] Table 2. Comparison of experimental results for three CNN schemes
[0053] The comparative experimental results above show that the fabric texture detection method based on complementary fusion of spatial and frequency domain features proposed in this invention has good model independence and can effectively improve the classification performance of fabric texture when using different types of feature extraction backbone networks.
[0054] Based on the above-described preferred embodiments of the present invention, and through the foregoing description, those skilled in the art can make various changes and modifications without departing from the inventive concept. The technical scope of this invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.
Claims
1. A method of defect detection of a fabric, characterized by, The method comprises the following steps: Step 1: Collecting fabric images of different textures; Step 2: Inputting the spatial domain map into any one of the first to sixth layers, any one of the seventh to tenth layers, and any one of the eleventh to twelfth layers of the spatial domain encoder of the ViT-S model, to output a spatial domain first layer block vector, a spatial domain second layer block vector, and a spatial domain third layer block vector; Inputting the frequency domain map into any one of the first to sixth layers, any one of the seventh to tenth layers, and any one of the eleventh to twelfth layers of the frequency domain encoder of the ViT-S model, to output a frequency domain first layer block vector, a frequency domain second layer block vector, and a frequency domain third layer block vector; Inputting the spatial domain first layer block vector, the spatial domain second layer block vector, and the spatial domain third layer block vector into a TPP module to obtain a spatial domain first fixed-length vector, a spatial domain second fixed-length vector, and a spatial domain third fixed-length vector; Inputting the frequency domain first layer block vector, the frequency domain second layer block vector, and the frequency domain third layer block vector into a TPP module to obtain a frequency domain first fixed-length vector, a frequency domain second fixed-length vector, and a frequency domain third fixed-length vector; Inputting the frequency domain first fixed-length vector into an MLP layer and then inputting the frequency domain first fixed-length vector and the spatial domain first fixed-length vector into a FiLM module to obtain a fused first layer feature; Inputting the frequency domain second fixed-length vector into an MLP layer and then inputting the frequency domain second fixed-length vector and the spatial domain second fixed-length vector into a FiLM module to obtain a fused second layer feature; Performing a Concat operation on the fused first layer feature, the fused second layer feature, the spatial domain third layer block vector, the frequency domain first layer block vector, the frequency domain second layer block vector, and the frequency domain third layer block vector, and then inputting the result into a classifier to output a classification result.
2. The fabric defect detection method according to claim 1, wherein, The model of the spatial domain encoder and the frequency domain encoder of the block vector further comprises a CNN model.
3. The fabric defect detection method according to claim 1, wherein The classifier comprises: a LayerNorm, a first fully connected layer, a second fully connected layer, and a Softmax layer connected in sequence.
4. The fabric defect detection method according to claim 1, wherein, The first layer block vector is the sixth layer, the second layer block vector is the tenth layer, and the third layer block vector is the twelfth layer.
5. The fabric defect detection method according to claim 1, wherein, The fabric images comprise normal images and abnormal images; the abnormal images comprise an auxiliary agent residual spot defect image, a jitter image, and a motion blur image.
6. The fabric defect detection method according to claim 1, wherein, The texture categories of the fabric comprise plain weave, twill weave, rib weave, double-sided weave, pit strip, high-density weave, and jacquard weave.
Citation Information
Patent Citations
Space domain-frequency domain combined enhanced steel member defect size intelligent measuring system
CN118761959A
Pollen detection method and system based on pollen scanning film
CN119851050A
Tumor image denoising and deblurring method based on long and short exposure tumor image
CN120563359A
High-fidelity dynamic scene video generation method based on single static image
CN120852780A
Image tampering detection method and device based on cross-modal ViT architecture
CN120953772A