Fabric defect detection method
Abstract
The present disclosure provides a fabric defect detection method, including the following steps: constructing a data set; preprocessing the data set; constructing a region-based convolutional neural network (R-CNN) model for fabric defect detection; where the R-CNN model for fabric defect detection includes four convolutional layers, four max-pooling layers, and two fully connected layers; training the R-CNN model for fabric defect detection; and reducing a number of false negative (FN) samples by classification threshold reduction. The present disclosure provides a novel R-CNN model for fabric defect detection. The model provides a desirable feature detection accuracy, has a low running cost, and is easy to implement, such that the model can be better applicable to actual operations in an industrial environment.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1 . A fabric defect detection method, comprising the following steps:
step 1: constructing a data set, comprising:
adopting four different data sets, wherein in addition to three existing data sets of TILDA, MVTec, and Stains, a new self-built data set is constructed; the self-built data set comprises two parts for a training phase and a testing phase, respectively; and the three existing data are only used during the testing phase;
wherein the self-built data set comprises images from two different sources in include fabric defect sample images from Cotton Incorporated and fabric images from network; the fabric defect sample images from Cotton Incorporated comprise 194 512×512 fabric images in six defect types for comprehensive representation of fabric defect categories: in order to supplement and increase a number of samples in the self-built data set, the fabric images from network comprise texture images in six defect types, wherein each defect typo comprises 200 non-defective image samples and 10 defective image samples, there is only one defect in each image, a total of 1,454 images re used as samples, and the images e an ed with an open source tool Labelme;
step 2: preprocessing the data set; step 3: constructing a region-based convolutional neural network (R-CNN) model for fabric defect detection; wherein the R-CNN model for fabric defect detection comprises four convolutional layers, four max-pooling layers, and two fully connected layers; step 4: training the R-CNN model for fabric defect detection; and step 5: reducing a number of false negative (FN) samples by classification threshold reduction.
2 . The fabric defect detection method according to claim 1 , wherein step 2 specifically-comprises:
(1) image size adjustment: scaling the fabric defect sample images from Cotton Incorporated and the fabric images from network in the self-built data set through a resize function; and on the basis of an original image aspect ratio of 512×512, conducting shrinking and testing, finding an image size suitable for the R-CNN model, and determining that an input size is fixed at 150×150; and (2) gray level transformation: a gray level of each pixel in the image is a weighted average of three monochromatic colors red (R), green (G), and blue (B):
D= 0.299 R+ 0.587 G+ 0.114 B
converting the images in the self-built data set into a gray level histogram, wherein the gray level of the pixel falls between 100 and 200, and details cannot be highlighted; correcting the gray level of the pixel in the image by gray level histogram equalization; a formula of the gray level histogram equalization is as follows:
h
(
v
)
=
round
(
cdf
(
v
)
-
cdf
(
min
)
cdf
(
max
)
-
cdf
(
min
)
)
×
(
L
-
1
)
L=256 is a gray level series, cdf is a cumulative distribution function, and min and max are minimum and maximum gray levels in the gray level histogram, respectively; and a round function returns an integer result after decimal rounding.
3 . The fabric defect detection method according to claim 2 , wherein step 3 specifically comprises:
the R-CNN model for fabric defect detection comprises the four convolutional layers, the four max-pooling layers, and the two fully connected layers; each of the four convolutional layers is connected with one of the four max-pooling layers, and a last one of the four max-pooling layers is sequentially connected with the two fully connected layers; the four max-pooling layers each have a convolution kernel size of 2×2; the following table shows the four convolutional layers, the four max-pooling layers, and the two fully connected layers, as well as hyperparameters, and an input image is 150×150×1;
Layer
Output feature map
Hyperparameter
Conv1
150 × 150 × 64
F = 64, K = 5, S = 1, p = 2
Max-pool 1
75 × 75 × 64
S = 2
Conv2
75 × 75 × 64
F = 64, K = 5, S = 1, p = 2
Max-pool 2
38 × 38 × 64
S = 2
Conv3
38 × 38 × 128
F = 128, K = 3, S = 1, p = 2
Max-pool 3
13 × 13 × 128
S = 3
Conv4
13 × 13 × 128
F = 128, K = 3, S = 1, p = 2
Max-pool 4
5 × 5 × 128
S = 3
Fully connected
256
Neuron 256
layer 1
Fully connected
128
Neuron 128
layer 2
F represents a number of feature maps, K represents the convolution kernel size, S represents a convolutional stride, and p represents padding; and a neuron activation function is ReLu; and
a loss function adopts binary cross-entropy loss, with a formula as follows:
Loss
=
-
1
N
∑
i
=
1
N
yi
·
log
(
p
(
yi
)
)
+
(
1
-
y
i
)
log
(
1
-
p
(
yi
)
)
y i is a label with a value of 1; and (y) is a prediction result of N samples, that is, a probability that a sample is a defective image.
4 . The fabric defect detection method according to claim 3 , wherein step 4 comprises:
conducting visualizing intermediate activation, and visually displaying the feature maps output by each of the four convolutional layers and the four max-pooling layers in a R-CNN to verify a training situation of the network; wherein the visualizing intermediate activation is conducive to displaying characteristics of false positive and false negative samples to better debug the R-CNN model; setting “batch_size” to 8, such that the R-CNN model selects batches of data each time during the training to allow processing to improve a training speed; and training the R-CNN model for fabric defect detection with a preprocessed self-built data set obtained in step 2 until the loss function reaches an optimal degree of convergence; and testing the R-CNN model for fabric defect detection on the four different testing data sets.
5 . The fabric defect detection method according to claim 4 , wherein step 5 comprises:
outputting a probability that a predicted image is a defect function through sigmoid using the fully connected layer 2 of the R-CNN for fabric defect detection, and mapping the probability to a binary classification, wherein a defective sample is defined as a positive sample P; two types of samples, false negative (FN) and false positive (FP) are generated; in an actual industrial environment, a number of fabrics with defects is much smaller than a number of fabrics without defects during mass production, that is, a number of positive samples P is much smaller than a number of negative samples N; a larger number of positive samples P and negative samples N that need to be manually reviewed and verified means a greater cost in manual review and verification; and a test result shows that the FN samples provided by an R-CNN network classifier for fabric defect detection are mostly close to a classification threshold, and an FN sample higher than the classification threshold is classified as a defective sample; after the classification threshold reduction is conducted, FN samples classified as non-defective samples by a detection system are reclassified as the defective samples to reduce an occurrence frequency of the FN samples; the reclassifying is conducted to better divide positive and negative categories of fabric samples and reduce the cost of manual review.Join the waitlist — get patent alerts
Track US12597113B2 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.