Fabric Defect Detection Method Based on Random Copy-Paste Data Augmentation

By generating fabric defect samples through random copy-paste data augmentation, and combining a deep learning platform and the ResNet18 model, the problems of insufficient and imbalanced samples in fabric defect detection are solved, thereby improving the detection rate and generalization ability.

CN115170546BActive Publication Date: 2025-10-31ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210899166.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-28
Publication Date
2025-10-31
Estimated Expiration
2042-07-28

AI Technical Summary

Technical Problem

Existing technologies lack sufficient defect samples for fabric defect detection, and the sample distribution is uneven, resulting in a low detection rate of the detection model. This is especially true in complex patterns such as yarn-dyed shirts, where the defects are highly similar to the background, leading to poor detection performance.

Method used

A data augmentation method based on random copy and paste is adopted. By constructing a network for randomly copying rectangles and filamentary regions, dynamic defect samples are generated. The ResNet18 model is trained using the deep learning platform PyTorch, and the classification model is optimized to improve the detection rate.

Benefits of technology

By generating a large number of feature samples similar to real defects, the detection rate of the fabric defect detection model was significantly improved, and it showed a good generalization effect on anomalies of unclear types, thus improving the accuracy and generalization ability of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115170546B_ABST
    Figure CN115170546B_ABST
Patent Text Reader

Abstract

This invention discloses a fabric defect detection method based on random copy-paste data augmentation. This method constructs a dynamic defect sample generation network using random copy-paste data augmentation, merging defect-free samples with dynamically constructed defect samples as model input. Simultaneously, a classification model is used for training, and after training, defect detection is performed on fabric pieces. Compared to other current methods, this invention can construct features similar to real defects, significantly improving the detection rate of the fabric defect detection model, and also has a good generalization effect on anomalies of unclear types.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer vision, and specifically relates to a fabric defect detection method based on Random Copy Paste Data Augmentation (RCDA). Background Technology

[0002] Raw material quality issues and uncertainties in shirt manufacturing can lead to defects such as holes, broken warp threads, and stains on yarn-dyed shirt pieces. Failure to detect and remove these defective pieces can result in quality problems and economic losses in the finished shirts. Therefore, fabric inspection is an essential step in the textile process, a crucial link in modern manufacturing quality control, and necessary for defect detection and product quality assessment. Given the need for high-quality inspection, automated fabric defect detection methods based on machine vision have attracted researchers' attention. By applying computer vision technology to automated fabric visual inspection, raw material waste can be reduced, costs saved, fabric quality stability ensured, and inspection efficiency improved.

[0003] Machine vision image processing is gradually replacing repetitive human recognition work. Compared with human eye recognition, machine vision has a stronger ability and accuracy in recognizing images. Statistical feature-based methods require too many parameters to identify and lack strong structure, and are initially only suitable for single-variable or systems with weak static relationships between process variables. Spectral feature-based methods are suitable for simple patterns, but when the defects are small and the contrast with the fabric texture is too low, the sensitivity of the detection model will be greatly affected. However, the patterns of yarn-dyed shirts are usually more complex, with smaller defects and higher similarity to the background. Model feature-based methods require building a separate model for each specific pattern, which is very costly. Structural feature-based methods are also difficult to apply to scenarios where there are multiple types of defects on the surface of yarn-dyed fabrics with different patterns.

[0004] With the advancement of computer hardware and its processing speed, the ability to process computer image data has continuously improved. Deep learning, a machine learning method that studies and solves the problem of expressing data features in deep neural networks, is widely used in image classification and recognition, especially in the automatic extraction of high-level abstract features from massive images, improving both classification accuracy and precision. To address the vanishing gradient problem that arises with increasing network depth, the deep residual network ResNet18 is employed. However, for supervised deep residual networks like ResNet18, a large number of defect samples are required for training to learn defect features for detection. Unlike typical supervised classification problems, anomaly detection faces unique challenges. First, due to the nature of the problem, it is difficult to obtain large amounts of anomaly data, whether labeled or unlabeled. Second, the differences between normal and anomalous patterns are often fine-grained, as defect regions may be small and subtle high-resolution images. For the supervised deep residual network ResNet18, it requires a large number of defect samples for training in order to learn defect features for detection. At the same time, during supervised single-class training, imbalanced data samples will bias the test results.

[0005] Data augmentation using geometric transformations of images, such as rotation or translation, alters the overall objectivity. However, most existing work focuses on detecting semantic outliers (e.g., different categories of visual objects) from natural images centered on local objects. In fabric defect detection, outliers typically include irregularities such as holes, broken warp threads, and stains, which are outliers of object regularity (e.g., continuity, repetition). Geometric transformations are suboptimal in detecting local defects. Summary of the Invention

[0006] To address the shortcomings of existing technologies, this invention provides a fabric defect detection method based on random copy-paste data augmentation, the specific technical solution of which is as follows:

[0007] A fabric defect detection method based on random copy-paste data augmentation includes the following steps:

[0008] (1) Construct a sample set for fabric defect detection;

[0009] Collect fabric images containing defect-free fabric pieces as the training set X. mn ∈R, where n=1,...,N, and N represents the number of samples;

[0010] (2) Take the training set {X} from step (1) mn Image preprocessing is performed, including adjusting the image resolution, converting pixel values ​​into tensors and then normalizing them, and changing the image properties.

[0011] (3) A defect sample dynamic generation network is built based on a deep learning platform. The defect sample dynamic generation network includes a random copy rectangular region pasting network, a random copy filament region pasting network, and a random number R used to determine the data augmentation method. The range factor area_ration of the copied image area in the defect sample dynamic generation network is set, and the factor aspect_ration of converting the copied image area into the copied width and height is set. The filament region is the area where the defect similar to a snag is located in the fabric.

[0012] (4) The replication region V is dynamically obtained through the defect sample dynamic generation network. mn and compared it with the original defect-free fabric sample X mn Merge into defect samples

[0013] (5) Defect samples Compared with the original input defect-free sample X mn Together they form a new training set, which is then labeled as

[0014] (6) Use the new training set obtained in step (5) to train the classification model to obtain the optimized classification model;

[0015] (7) Repeat the image preprocessing operation of step (2) on the fabric image to be detected, and then input it into the optimized classification model obtained in step (6). The model outputs the defect category of the fabric image to be detected.

[0016] Furthermore, step (2) specifically includes:

[0017] For the training set X = {X mn Image preprocessing is performed on n=1,…,N; each image is randomly selected from the training set X, the image resolution is adjusted to 256*256, the original image is converted into the corresponding pixel value in RGB mode, the pixel value is converted into a tensor and then normalized, and the image attributes are changed so that the brightness, contrast, saturation and hue are all adjusted to 10% of the original input.

[0018] Furthermore, step (3) specifically includes:

[0019] 1) The construction of the random copy rectangular region pasting network consists of the following four steps:

[0020] (a) Set the range factor area_ration for randomly copying block regions, and the conversion factor aspect_ration for converting block regions to their corresponding width and height;

[0021] (b) Randomly select a value r within the range factor region area_ration, and then calculate the area of ​​the rectangular region to be copied:

[0022] S = r * w α *h α (1)

[0023] Among them, w α and h α These are the width and height of the input image, respectively;

[0024] (c) Convert the area of ​​the rectangular region to be copied to the corresponding width w using the conversion factor aspect_ration. β and high h β :

[0025]

[0026] (d) Then, randomly select the starting position of the rectangular area to be copied, and randomly rotate and dither the selected rectangular area:

[0027] x α =random(0,w α -w β (4)

[0028] y α =random(0,h) α -h β (5)

[0029] S * =Rotate&Jitter(S) (6)

[0030] Where, x α The x-coordinate of the starting position of the randomly selected rectangular region to be copied is represented by the coordinate y. α S represents the ordinate of the starting position of the randomly selected rectangular region to be copied. * This represents the area of ​​the rectangular region obtained after random rotation and pixel dithering of the selected rectangular region.

[0031] (e) Randomly select the location of the rectangle to be pasted, and paste the randomly selected rectangle to the randomly selected location;

[0032] x β =random(0,w α -w β (7)

[0033] y β =random(0,h) α -h β (8)

[0034] Where, x β The x-coordinate of the pasted rectangular area, y β This represents the ordinate of the position of the pasted rectangular area;

[0035] 2) The construction of the randomly replicated filamentary region pasting network consists of the following three steps:

[0036] (a) Set the width range factor w, the height range factor h, and the random transparency range factor a of the filamentary region;

[0037] (b) Randomly obtain the width w of the filamentary region to be replicated from the width range factor w and the height range factor h of the filamentary region. * and height h * Randomly select the starting position of the filamentous region to be copied:

[0038] x α =random(0,w α -w * (9)

[0039] y α =random(0,h) α -h * (10)

[0040] Among them, w α and h α x is the width and height of the input image. α Let y be the x-coordinate of the starting position of the filamentary region to be copied. α The ordinate represents the starting position of the filamentous region to be copied;

[0041] (c) Randomly rotate and jitter the obtained filamentary region S, and add a randomly selected transparency a. * property:

[0042] S = w * *h * (11)

[0043] S * =(Rotate&Jitter(S),a * (12)

[0044] S * The area of ​​the filamentary region after random rotation and pixel jitter;

[0045] (d) Randomly select the position of the rectangular area to be pasted, and paste the silk-like area to the randomly selected position;

[0046] x β =random(0,w α -w * (13)

[0047] y β =random(0,h) α -h * (14)

[0048] x β The x-coordinate of the location of the pasted filamentary region is y. β The vertical coordinate represents the location of the pasted filamentous area;

[0049] 3) Based on the random number R, randomly copy a rectangular region and paste it into the network or randomly copy a filamentary region and paste it into the network for data augmentation.

[0050] Further, step (4) specifically involves: copying the input image region V obtained through the defect sample dynamic generation network. mn Compared with the original defect-free fabric image X mn Merge into defect samples

[0051]

[0052] Further, step (5) specifically involves: processing defective samples Compared with the original input defect-free sample X mn Together they form a new training set X * And label the training set:

[0053]

[0054] Furthermore, step (6) specifically includes:

[0055] 1) ResNet18 was chosen as the classification model. The basic network structure of the ResNet18 network model is the residual block. The residual block consists of two parts. The first part includes a convolutional layer with a 3*3 kernel, a normalization layer to make the neural network converge faster and better, a ReLU layer to make the data sparsity, a convolutional layer with a 3*3 kernel, and a normalization layer. The second part is to process the input to the same size as the output of the first part. The two parts are added together to form the residual block.

[0056] 2) Implement the ResNet18 network model using residual blocks. The ResNet18 network model has six layers. The first layer is a convolutional layer with a 7*7 kernel. The second layer consists of a max pooling layer and two residual blocks. The third, fourth, and fifth layers each consist of two residual blocks. The sixth layer is a fully connected layer as the output.

[0057] The loss function is defined as:

[0058] L=E x∈X {CE(g(x),0)+CE(g(C(x)),1)} (17)

[0059] Where X is the original input training set, CE(*) is the cross-entropy loss, g is the ResNet18 binary classifier, and C(*) is the model that uses a defect sample dynamic generation network for data augmentation.

[0060] Meanwhile, the hidden layer output node m of the ResNet18 network model is set, and the number of training epochs and batch size are set. The loss function is optimized by using the stochastic gradient descent method. The learning rate, decay weight w, and momentum factor m are set for model training.

[0061] The beneficial effects of this invention are as follows:

[0062] This invention utilizes a DefectSample Dynamic Generated network, constructed by randomly copying and pasting data augmentation onto fabric images, to process fabric sample data and generate a large number of defect samples, thus overcoming the shortage of existing defect samples. These defect samples are then combined with non-defect samples to form a training set, which is used to train a classification model and construct a fabric detection model. Compared to other current methods, this invention can construct features similar to real defects, significantly improving the detection rate of the fabric defect detection model, while also demonstrating excellent generalization capabilities for anomalies of unclear types. Attached Figure Description

[0063] Figure 1 This is a schematic diagram of the ResNet18 model structure;

[0064] Figure 2 This is a schematic diagram of a network for dynamically generating defective samples;

[0065] Figure 3 This is a diagram showing the results of fabric defect detection using a basic ResNet18 model.

[0066] Figure 4 This is a result image of fabric defect detection based on randomly copied rectangular area pasting network;

[0067] Figure 5 This is a result image of fabric defect detection based on a randomly copied filamentous region pasted network;

[0068] Figure 6 This is a result image of fabric defect detection based on random copy-paste data augmentation;

[0069] Figure 7 This is a TSNE graph for fabric defect detection based on random copy-paste data augmentation. Detailed Implementation

[0070] The present invention will be described in detail below with reference to the accompanying drawings and preferred embodiments. The purpose and effects of the present invention will become clearer. It should be understood that the specific embodiments described herein are merely for explaining the present invention and are not intended to limit the present invention.

[0071] This invention presents a fabric defect detection method based on random copy-paste data augmentation, designed to address the problems of limited and unevenly distributed defect samples in fabric defect detection. This invention can construct features similar to real defects, significantly improving the detection rate of the fabric defect detection model, and also has a good generalization effect on anomalies of unclear types.

[0072] The method of the present invention specifically includes the following steps:

[0073] Step 1: Construct a sample set for fabric defect detection;

[0074] In this embodiment, a sample set collected by Guangdong Esquel Textile Co., Ltd. is used, which includes both defective and non-defective samples. The samples are divided into a training set and a test set, with the training set containing only non-defective samples X. mn ∈R 512*512 The test set contains defect sample X lu ∈R 512*512 and defect-free sample X ln ∈R 512*512 Where n = 1, ..., N, u = 1, ..., N, N represents the number of samples, and 512 is the original pixel size of the image. This data is stored in a historical database.

[0075] Step 2: For the training set (X = {X_1}) in the historical dataset... mn Image preprocessing is performed on images (n = 1, ..., N). Each image is randomly selected from the training set X, its resolution is adjusted to 256*256, and the `convert` function in the PIL module is used to convert the original image to its corresponding pixel values ​​in RGB mode. The pixel values ​​are then converted to tensors and normalized. Image attributes are adjusted so that brightness, contrast, saturation, and hue are all reduced to 10% of the original input. Image preprocessing eliminates irrelevant information in the image, enhances the detectability of relevant information, and simplifies the data to the maximum extent.

[0076] Step 3: Build a dynamic defect sample generation network based on a deep learning platform. This network includes a network for randomly copying and pasting rectangular regions, a network for randomly copying and pasting filamentary regions, and a random number R that determines the data augmentation method. Figure 2 As shown;

[0077] In this embodiment, the deep learning platform is PyTorch. The construction of the network for randomly copying rectangular regions consists of the following four steps:

[0078] (a) Set the range factor area_ration for randomly copying block regions, and the conversion factor aspect_ration for converting block regions to their corresponding width and height;

[0079] (b) Randomly select a value r within the range factor region area_ration, and then calculate the area of ​​the rectangular region to be copied:

[0080] S = r * w α *h α (1)

[0081] Among them, w α and h α These are the width and height of the input image, respectively;

[0082] (c) Convert the area of ​​the rectangular region to be copied to the corresponding width w using the conversion factor aspect_ration. β and high h β :

[0083]

[0084] (d) Then, randomly select the starting position of the rectangular area to be copied, and randomly rotate and dither the selected rectangular area:

[0085] x α =random(0,w α -w β (4)

[0086] y α =random(0,h) α -h β (5)

[0087] S * =Rotate&Jitter(S) (6)

[0088] Where, x α The x-coordinate of the starting position of the randomly selected rectangular region to be copied is represented by the coordinate y. α S represents the ordinate of the starting position of the randomly selected rectangular region to be copied. * This represents the area of ​​the rectangular region obtained after random rotation and pixel dithering of the selected rectangular region.

[0089] (e) Randomly select the location of the rectangular area to be pasted, and paste the randomly selected rectangular area to the randomly selected location;

[0090] x β =random(0,w α -w β (7)

[0091] y β =random(0,h) α -h β (8)

[0092] Where, x β The x-coordinate of the pasted rectangular area, y β This is the ordinate of the position of the pasted rectangular area.

[0093] 2) The construction of the randomly replicated filamentary region pasting network consists of the following three steps:

[0094] (a) Set the width range factor w, the height range factor h, and the random transparency range factor a of the filamentary region;

[0095] (b) Randomly obtain the width w of the filamentary region to be replicated from the width range factor w and the height range factor h of the filamentary region. * and height h * Randomly select the starting position of the filamentous region to be copied:

[0096] x α =random(0,w α -w * (9)

[0097] y α =random(0,h) α -h * (10)

[0098] Among them, w α and h α x is the width and height of the input image. α Let y be the x-coordinate of the starting position of the filamentary region to be copied. α The ordinate represents the starting position of the filamentous region to be copied;

[0099] (c) Randomly rotate and jitter the obtained filamentary region S, and add a randomly selected transparency a. * property:

[0100] S = w * *h * (11)

[0101] S * =(Rotate&Jitter(S),a * (12)

[0102] S * The area of ​​the filamentary region after random rotation and pixel jitter;

[0103] (d) Randomly select the position of the rectangular area to be pasted, and paste the silk-like area to the randomly selected position;

[0104] x β =random(0,w α -w * (13)

[0105] y β =random(0,h) α -h * (14)

[0106] x β The x-coordinate of the location of the pasted filamentary region is y. β The vertical coordinate represents the location of the pasted filamentous area;

[0107] 3) Based on the random number R, randomly copy a rectangular region and paste it into the network or randomly copy a filamentary region and paste it into the network for data augmentation.

[0108] Step 4: Dynamically obtain the replication region V using the defect sample dynamic generation network. mn and compared it with the original defect-free fabric sample X mn Merge into defect samples

[0109]

[0110] Step 5: Defect Samples Compared with the original input defect-free sample X mn Together they form a new training set, which is then labeled as

[0111]

[0112] Step Six: Train the classification model using the new training set obtained in Step Five to obtain the optimized classification model;

[0113] 1) ResNet18 was chosen as the classification model. The basic network structure of the ResNet18 network model is the residual block. The residual block consists of two parts. The first part includes a convolutional layer with a 3*3 kernel, a normalization layer to make the neural network converge faster and better, a ReLU layer to make the data sparsity, a convolutional layer with a 3*3 kernel, and a normalization layer. The second part is to process the input to the same size as the output of the first part. The two parts are added together to form the residual block.

[0114] 2) Implement the ResNet18 network model using residual blocks, such as... Figure 1 As shown, the ResNet18 network model has six layers. The first layer is a convolutional layer with a 7*7 kernel. The second layer consists of a max pooling layer and two residual blocks. The third, fourth, and fifth layers each consist of two residual blocks. The sixth layer is a fully connected layer as the output.

[0115] The loss function is defined as:

[0116] L=E x∈X {CE(g(x),0)+CE(g(C(x)),1)} (17)

[0117] Where X is the original input training set, CE(*) is the cross-entropy loss, g is the ResNet18 binary classifier, and C(*) is the model that uses a defect sample dynamic generation network for data augmentation.

[0118] Meanwhile, the hidden layer output node m of the ResNet18 network model is set, and the number of training epochs and batch size are set. The loss function is optimized by using the stochastic gradient descent method. The learning rate, decay weight w, and momentum factor m are set for model training.

[0119] Step 7: Following the training in Step 6, a fabric defect detection model based on novel random copy-paste data augmentation is obtained for fabric images. The test set {(X... ln ,y ln ),(X lu ,y lu Repeat the image preprocessing steps in step two, and then input the results into the model to obtain the corresponding predicted values.

[0120] To validate the effectiveness of the fabric defect detection model based on random copy-paste data augmentation, the model evaluation metrics of accuracy, precision, recall, and F1-score were used, and TSNE images were plotted to evaluate the performance of the fabric defect detection model.

[0121]

[0122]

[0123] In this diagram, TP (True Positive) indicates that the true value is positive and is correctly predicted as positive; TN (True Negative) indicates that the true value is negative and is correctly predicted as negative; FP (False Positive) indicates that the true value is negative and is incorrectly predicted as positive; and FN (False Negative) indicates that the true value is positive and is incorrectly predicted as negative. The TSNE plot reduces the dimensionality of real fabric defect image data and dynamically generated structural defect image data and visualizes them.

[0124] The effectiveness of this invention will be verified using a specific industrial example. Guangdong Esquel Textile Co., Ltd. is a large-scale export-oriented and high-tech textile enterprise established by the Esquel Group. In its production process, spinning, dyeing, and weaving are all completed in a fully intelligent, modern cotton mill. The finished fabrics undergo a sample collection stage. Uncertain factors during the production process can lead to quality problems in the finished products. However, manual inspection is inefficient and struggles to detect defects in fabrics with small particle sizes. In this situation, it is necessary to establish a detection model using the sampled data to detect defects in dyed fabrics.

[0125] The implementation steps of the present invention will now be described in detail with reference to this specific process:

[0126] 1. The experimental setup is a deep learning workstation, and a sample set of colored fabric images is constructed. The samples are from Guangdong Esquel Textile Factory, and there are 66 different colored fabric pieces. The sample set of colored fabric images includes three categories: simple checkered patterns, striped patterns, and complex checkered patterns. Each pattern in each category of the sample set has a training set and a test set. The training set contains images of defect-free colored fabrics, while the test set contains images of defective and defect-free colored fabrics.

[0127] 2. A defect sample dynamic generation network model was built on the deep learning platform PyTorch. When constructing the network, the range factor `area_ration` for randomly replicating block regions was set to [0.02, 0.15], the conversion factor `aspect_ration` for converting block regions to their corresponding width and height was set to 0.3, the width range factor `w` for filamentary regions was set to [2, 16], the height range factor `h` for filamentary regions was set to [10, 25], and the random transparency range factor `a` for filamentary regions was set to [-45, 45]. The threshold `R` was set to 0.5. When training the ResNet18 model, the hidden layer output nodes were set to 512*8+128, the number of training epochs was set to 256, the batch size was set to 64, the learning rate was set to 0.03, the decay weights were set to 0.00003, and the momentum factor was set to 0.9.

[0128] 3. After the defect sample dynamic generation network is constructed, the training data is input into the defect sample dynamic generation network to obtain dynamically constructed defect samples from the training data. These defect samples are then merged with the original input non-defect samples to form a new training set. The training set is then labeled and used as input to the ResNet18 model. This is used to train the ResNet18 model, resulting in a fabric defect detection model based on novel random copy-paste data augmentation for colored fabric images.

[0129] 4. Based on the aforementioned dataset and model hyperparameter settings, a fabric defect detection model for colored fabric images based on random copy-paste data augmentation, as proposed in this invention, was constructed. Its prediction performance was compared with that of the basic ResNet18 model and the data-augmented ResNet18 model on the test set. The prediction results are shown below. Figure 3 , Figure 4 , Figure 5 , Figure 6 and Figure 7 As can be seen, the method proposed in this invention effectively constructs defects in yarn-dyed fabrics and achieves the best prediction results. Meanwhile, the model evaluation metrics, including accuracy, precision, recall, and F1-score, are listed in Table 1. Comparative results show that the yarn-dyed fabric defect detection method proposed in this invention can effectively utilize a large number of defect-free yarn-dyed fabric image samples to construct a deep learning model that dynamically generates defects, and its performance is significantly better than existing yarn-dyed fabric defect detection models. Figure 7 For the t-SNE plot used to train the model, randomly copied and pasted data augmentation defect examples hardly overlap with real defect examples. This indicates that the defects constructed by the data augmentation strategy proposed in this invention are still not perfect simulations of real defects, but learning them to discover irregularities has a good generalization effect on unseen anomalies.

[0130] Table 1: Figures 3 to 6 Comparison of model prediction performance

[0131] Indicators / Models ResNet18 CopyPaste(rectangle) CopyPaste(scar) CopyPaste Accuracy 0.641 0.980 0.969 0.977 Precision 0.650 0.988 0.969 0.978 Recall 0.642 0.985 0.969 0.977 F1 score 0.642 0.985 0.969 0.977

[0132] It will be understood by those skilled in the art that the above descriptions are merely preferred examples of the invention and are not intended to limit the invention. Although the invention has been described in detail with reference to the foregoing examples, those skilled in the art can still modify the technical solutions described in the foregoing examples or make equivalent substitutions for some of the technical features. All modifications and equivalent substitutions made within the spirit and principles of the invention should be included within the scope of protection of the invention.

Claims

1. A fabric defect detection method based on random copy-paste data augmentation, characterized in that, Includes the following steps: (1) Construct a sample set for fabric defect detection; Collect fabric images containing defect-free fabric pieces as the training set. ,in , Represents the number of images; (2) Take the training set from step (1) Image preprocessing includes adjusting image resolution, converting pixel values ​​into tensors and then normalizing them, and changing image properties. (3) A defect sample dynamic generation network is built based on a deep learning platform. The defect sample dynamic generation network includes a random copy rectangular region pasting network, a random copy filament region pasting network, and a random number generator used to determine the data augmentation method. ; And set the range factor of the area of ​​the copied image in the defect sample dynamic generation network. And the factor that converts the area of ​​the copied image into the width and height of the copied image. The filamentous region is the area in the simulated fabric where a defect similar to a snag is located. (4) The replication region is dynamically obtained through the defect sample dynamic generation network. and with Merged into a defect sample set ; (5) Defect sample set and Together they form a new training set, which is then labeled as ; (6) Use the new training set obtained in step (5) to train the classification model and obtain the optimized classification model; (7) Repeat the image preprocessing operation of step (2) on the fabric image to be detected, and then input the optimized classification model obtained in step (6). The model outputs the defect category of the fabric image to be detected.

2. The fabric defect detection method based on random copy-paste data augmentation according to claim 1, characterized in that, Step (2) specifically involves: For the training set Perform image preprocessing: randomly select each image from the training set X, adjust the image resolution to 256*256, convert the original image to the corresponding pixel value using RGB mode, convert the pixel value to a tensor and normalize it, and change the image attributes so that the brightness, contrast, saturation and hue are all adjusted to 10% of the original input.

3. The fabric defect detection method based on random copy-paste data augmentation according to claim 1, characterized in that, The specific steps (3) are as follows: 1) The construction of the random copy rectangular region pasting network consists of the following four steps: (a) Set the range factor for randomly replicated block regions And the factor that converts block regions into corresponding replication width and height. ; (b) in We randomly select a value r and then calculate the area of ​​the rectangular region to be copied: (1) in, and These are the width and height of the input image, respectively; (c) Utilize Convert the area of ​​the rectangular region to be copied to its corresponding width. and high : (2) (3) (d) Then, randomly select the starting position of the rectangular area to be copied, and randomly rotate and dither the selected rectangular area: (4) (5) (6) in, The x-coordinate represents the starting position of the randomly selected rectangular region to be copied. The ordinate represents the starting position of the randomly selected rectangular region to be copied. This represents the area of ​​the rectangular region obtained after random rotation and pixel dithering of the selected rectangular region. (e) Randomly select the location of the rectangle to be pasted, and paste the randomly selected rectangle to the randomly selected location; (7) (8) in, This is the x-coordinate of the position of the pasted rectangular area. This represents the ordinate of the position of the pasted rectangular area; 2) The construction of the randomly replicated filamentary region pasting network consists of the following three steps: (a) Set the width range factor of the filamentary region Height range factor of filamentous region and the random transparency range factor of the filamentary region. ; (b) Width range factor from the filamentous region and the height range factor of the filamentous region The width of the filamentary region to be copied is randomly obtained. and height Randomly select the starting position of the filamentous region to be copied: (9) (10) in, and Given the width and height of the input image, Let x be the x-coordinate of the starting position of the filamentous region to be copied. The ordinate represents the starting position of the filamentous region to be copied; (c) The obtained filamentous region Perform random rotation and pixel dithering, and add randomly selected transparency. property: (11) (12) The area of ​​the filamentary region after random rotation and pixel jitter; (d) Randomly select the position of the rectangular area to be pasted, and paste the silk-like area to the randomly selected position; (13) (14) This represents the x-coordinate of the location of the pasted filamentous area. The vertical coordinate represents the location of the pasted filamentous area; 3) Based on random numbers Choose to randomly copy a rectangular region and paste it into the network, or randomly copy a filamentary region and paste it into the network for data augmentation.

4. The fabric defect detection method based on random copy-paste data augmentation according to claim 1, characterized in that, Step (4) specifically involves: copying the input image region obtained through the defect sample dynamic generation network. ,and Merged into a defect sample set : (15)。 5. The fabric defect detection method based on random copy-paste data augmentation according to claim 1, characterized in that, Step (5) specifically involves: setting up the defect sample set. and Together they form a new training set And label the training set: (16)。 6. The fabric defect detection method based on random copy-paste data augmentation according to claim 1, characterized in that, The specific steps (6) are as follows: 1) ResNet18 was chosen as the classification model. The basic network structure of the ResNet18 network model is the residual block. The residual block consists of two parts. The first part includes a convolutional layer with a 3*3 kernel, a normalization layer to make the neural network converge faster and better, a ReLU layer to make the data sparsity, a convolutional layer with a 3*3 kernel, and a normalization layer. The second part is to process the input to the same size as the output of the first part. The two parts are added together to form the residual block. 2) Implement the ResNet18 network model using residual blocks. The ResNet18 network model has six layers. The first layer is a convolutional layer with a 7*7 kernel. The second layer consists of a max pooling layer and two residual blocks. The third, fourth, and fifth layers each consist of two residual blocks. The sixth layer is a fully connected layer as the output. The loss function is defined as: (17) in, The original input training set, It is cross-entropy loss. For ResNet18 binary classifier, This is a model for data augmentation using a network that dynamically generates defective samples; At the same time, the hidden layer output nodes of the ResNet18 network model are set. And set the number of model training cycles. and training batch data size The loss function is optimized using the stochastic gradient descent method, and the learning rate is set during model training. Decay weight and momentum factor .

Citation Information

Patent Citations

  • Industrial product surface defect detection method based on sample enhancement

    CN111161243A

  • Data enhancement method and device for micro defect detection rate

    CN111862097A