Wood floor color classification and defect detection method based on semi-supervised multi-task detection
By combining the grayscale world and perfect reflection algorithms for color correction with the Color-RCNN model, and utilizing a semi-supervised prediction monitoring network to generate and filter pseudo-labels, the reliance on manually labeled datasets in wood flooring classification and defect detection is resolved, thereby improving the efficiency and accuracy of the model.
Patent Information
- Application Number
- CN202310578316.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-22
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2043-05-22
AI Technical Summary
Existing wood flooring classification and defect detection models require large amounts of manually labeled datasets, resulting in low efficiency.
A color correction formula based on the gray-world algorithm and the perfect reflection algorithm is combined, and the Color-RCNN model is used for training. Pseudo-labels are generated through a semi-supervised prediction and monitoring network to filter out erroneous labels, thus achieving semi-supervised learning.
It improves the model's generalization ability and the accuracy of pseudo-labels, reduces the reliance on manually labeled data, and enhances the efficiency and accuracy of wood flooring color classification and defect detection.
Smart Images

Figure CN116596891B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of wood floor color classification and defect detection, and in particular relates to a wood floor color classification and defect detection method based on semi-supervised multi-task detection. Background Art
[0002] Color classification and defect detection are two important technical fields in the production and processing of wooden flooring. Based on the traditional methods, these two fields have been greatly improved with the development of computer vision and artificial intelligence technology. For color classification, the application of image processing technology, feature extraction technology and machine learning technology makes the classification of wooden floor colors more accurate and efficient; for defect detection, the application of image processing technology, feature extraction technology and deep learning technology makes the detection of wooden floor defects more accurate and automated. At present, the disadvantage of mainstream wooden floor classification and detection models is that they require a large number of manually labeled data sets, which takes a lot of time and is inefficient.
[0003] On this basis, an invention patent application with publication number CN103761743A discloses a floor defect detection method based on deep learning. This detection method automatically extracts key features and eliminates the manual feature extraction process, thereby improving efficiency. However, it still requires a large number of manually labeled images as data sets. Summary of the invention
[0004] Purpose of the invention: To address the deficiencies in the prior art, a method for wood floor color classification and defect detection based on semi-supervised multi-task detection is provided.
[0005] Technical solution: In order to solve the above technical problems, the technical solution adopted by the present invention is as follows:
[0006] Collect wooden floor images and use the color correction formula based on the gray world algorithm and the perfect reflection algorithm to correct the defective color; mark a small number of images as data sets and input them into the Color-RCNN model improved by Faster-RCNN for training to achieve color classification and defect detection of wooden floors; use the detection boxes in the marked images as positive samples, and randomly draw boxes on the unlabeled images as negative samples, and train the semi-supervised prediction monitoring network designed based on the convolutional neural network to determine whether the pseudo-labels are accurate; use the trained Color-RCNN model to predict the remaining unlabeled images to achieve color classification and generate pseudo-labels, and use the semi-supervised prediction monitoring network to judge the pseudo-labels, keep the correctly identified detection boxes, and filter out the wrong detection boxes; add the correctly identified images to the data set, re-input the Color-RCNN model for training, and predict the remaining unlabeled images until all unlabeled images have reliable labels to achieve semi-supervised learning.
[0007] As a preference, the method comprises the following steps:
[0008] S1: Collect images of wooden floors with various colors and defects, mark the color categories of a small number of wooden floors and select the defect locations as marked images, and the rest as unmarked images. Since defects may affect the color recognition of wooden floors, the color of wooden floors is corrected according to the defect color correction formula, see formula 1-4;
[0009] S2: Use labeled images to train a Color-RCNN model, see Figure 3 , achieving color classification and defect detection of wooden floors;
[0010] S3: Take the detection boxes of the labeled images as positive samples, randomly draw boxes on some images as negative samples, build a dataset containing positive and negative samples, and train a semi-supervised prediction monitoring network, see Figure 4 , the input is the feature representation of ROI and the category of ROI, and the output is whether the ROI is a reliable pseudo label, judging whether the pseudo label is accurate;
[0011] S4: Use the trained Color-RCNN model to predict the remaining unlabeled images, implement color classification, generate pseudo labels, and use the semi-supervised prediction monitoring network to discriminate the pseudo labels, retain the correctly identified detection frames, and filter out the wrong detection frames;
[0012] S5: The filtered unlabeled images are combined with the labeled images, and the Color-RCNN model is retrained to predict the remaining unlabeled images until all unlabeled images have reliable labels to achieve semi-supervised learning.
[0013] Preferably, in step S1, a color corrector based on a combination of a grayscale world and perfect reflection is used to correct the color of the wooden floor, and the defect area ratio is used as an influencing parameter. The distribution of the defect area ratio can be described by a kernel function g(x), which can be used as a weight factor and multiplied with the original color correction formula. By performing Fourier transform on the kernel function, it can be converted from the time domain to the frequency domain, so as to better perform color correction on the image. Calculate the mean of the three RGB channels to obtain R avg , G avg and B avg , calculate the maximum value of each of the three channels of RGB, and get R max , G max and B max , select the Gaussian kernel function. The color correction formula based on the combination of the gray world algorithm and the perfect reflection algorithm is as follows:
[0014]
[0015] Among them, R corrrepresents the R channel correction value considering the defect area and distribution, G corr represents the G channel correction value considering the defect area and distribution, B corr It represents the B channel correction value considering the defect area and distribution, R avg represents the average value of R channel, G avg represents the average value of G channel, B avg Indicates the average value of B channel, R max Indicates the maximum value of R channel, G max Indicates the maximum value of G channel, B max represents the maximum value of channel B, G(f) represents the Fourier transform of the kernel function g(x), g(x) represents the Gaussian kernel function describing the distribution of the defect area, f represents the frequency, A represents the total area of multiple defects in the wooden floor, and x represents the area of a single defect. Expanding the Fourier transform and inverse transform process, we can get:
[0016]
[0017] Next, we can combine the exponential terms to get:
[0018]
[0019] Finally, we can take x out of the integral and get:
[0020]
[0021] in, represents the value of the kernel function in the frequency domain, which can be obtained by inverse Fourier transform. When the defect area distribution is more uniform, The value of will be more concentrated in the low frequency part, and vice versa will be more dispersed in the high frequency part. The value of can be used to indicate the influence of defect area distribution on color. In the color correction formula, By convolving or integrating with x, we can get the color correction value that takes into account the influence of the defect area distribution.
[0022] Preferably, in step S2, a Color-RCNN model is designed based on Faster-RCNN. A color prediction network is used for color classification, and the network includes a convolutional layer and a fully connected layer. The input is the ROI (region of interest) of the defect area output by PyramidROIAlign and the output result of the FPN_Classifier network, and the output is the color classification result. The FPN_Classifier network is cascaded with the color prediction network, and the classification and BB regression results of the ROI output by the FPN_Classifier network are input into the color prediction network, so that it can perform target detection and color classification at the same time.
[0023] Preferably, the specific implementation method of step S2 is as follows:
[0024] S21: First, input the labeled image and perform data preprocessing;
[0025] S22: Pass the processed image into ResNet-101+FPN to obtain the corresponding feature map and extract the input features of the color classifier;
[0026] S23: Setting ROI for each point in the feature map to obtain multiple ROI candidate boxes;
[0027] S24: Send these multiple ROI candidate boxes to RPN for binary classification (foreground or background) and BB regression (Bounding-box regression), and filter out some candidate ROIs;
[0028] S25: Perform ROIAlign operation on the remaining ROIs, use bilinear interpolation to accurately convert each ROI to the same size, first match the pixels of the original image and the feature map, and then match the feature map with the fixed feature;
[0029] S26: Input the ROI after Pyramid ROIAlign into the FPN_Classifier network to obtain the classification and BB regression results of each ROI;
[0030] S27: Input the ROI after Pyramid ROI Align and the classification and BB regression results of each ROI into the color prediction network to obtain the color classification result;
[0031] S28: Combine the color classification results with the target detection results to obtain the final target detection and color classification results, calculate the loss function of target detection and color classification, use the back propagation algorithm to update the network parameters, and repeat steps S21-S28 until the predetermined number of training rounds or convergence is reached.
[0032] Preferably, the specific implementation method of step S3 is as follows:
[0033] S31: Take the detection box of the labeled image as the positive sample, and randomly draw the box on the unlabeled image as the negative sample, and construct a data set containing positive and negative samples;
[0034] S32: Train the semi-supervised prediction monitoring network and use the positive sample and negative sample data sets for binary classification. After the training, the network can make reliability judgments on the pseudo labels generated by the unlabeled images.
[0035] S33: Reliable pseudo labels are screened out through the semi-supervised prediction monitoring network and added to the labeled dataset to retrain Color-RCNN. The unreliable pseudo labels are used as part of the unlabeled dataset to continue semi-supervised learning.
[0036] Preferably, the structure of the semi-supervised predictive monitoring network includes a convolution layer, a pooling layer and a fully connected layer, wherein the convolution layer 1 uses 32 3x3 convolution kernels with a step size of 1 and a ReLU activation function to input image data and extract image features. The pooling layer 1 uses a 2x2 maximum pooling kernel with a step size of 2 to downsample and reduce the size of the feature map. The convolution layer 2 uses the result of the pooling layer 1 as input to extract higher-level features. The convolution layer 2 uses 64 3x3 convolution kernels with a step size of 1 and a ReLU activation function. The pooling layer 2 uses a 2x2 maximum pooling kernel with a step size of 2 to downsample and reduce the size of the feature map. The convolution layer 3 uses the result of the pooling layer 2 as input. , continue to extract high-level features, convolution layer 3 uses 128 3x3 convolution kernels, step size 1, and ReLU activation function, pooling layer 3 uses 2x2 maximum pooling kernel, step size 2, downsampling, reduce the size of feature map; after a fully connected layer 1, the feature map is expanded into a one-dimensional vector, and a fully connected operation is performed. There are 256 neurons in total, and the ReLU activation function is used; after a Dropout layer, 50% of the neurons are randomly discarded to reduce overfitting; finally, after a fully connected layer 2, as the output layer, the Sigmoid activation function is used to classify the pseudo-labels into two categories, the output is 0 for the wrong pseudo-label, and the output is 1 for the correct pseudo-label.
[0037] Beneficial effects: Compared with the prior art, the advantages of the present invention include:
[0038] (1) By utilizing the information of labeled data and unlabeled data, data resources are fully utilized and the generalization ability of the model is improved.
[0039] (2) A color correction formula is proposed to correct the color of wooden floors, and a Color-RCNN model is proposed to perform color classification and defect detection on wooden floors, which improves the classification accuracy of the model and the quality of pseudo-labels.
[0040] (3) A semi-supervised predictive monitoring network is proposed to identify pseudo-labels, which can filter out erroneous pseudo-labels and enhance the accuracy of pseudo-labels. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 is a wood floor defect detection diagram of the present invention;
[0042] Figure 2 It is a schematic diagram of the classification and testing process of wooden flooring;
[0043] Figure 3 It is the Color-RCNN network structure diagram of the present invention;
[0044] Figure 4 It is a structural diagram of the semi-supervised prediction monitoring network of the present invention. DETAILED DESCRIPTION
[0045] The present invention is further illustrated below in conjunction with specific examples. The examples are implemented based on the technical solutions of the present invention. It should be understood that these examples are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0046] The method for color classification and defect detection of wooden floor based on semi-supervised multi-task detection of this embodiment is characterized in that the wooden floor image is collected and the defect color correction is performed using the color correction formula based on the combination of gray world algorithm and perfect reflection algorithm; a small number of images are marked as data sets and input into the Color-RCNN model improved by Faster-RCNN for training to achieve color classification and defect detection of wooden floor; the detection frame in the marked image is used as a positive sample, and the random frame on the unlabeled image is used as a negative sample, and the semi-supervised prediction monitoring network designed based on the convolutional neural network is trained to determine whether the pseudo-label is accurate; the trained Color-RCNN model is used to predict the remaining unlabeled images to achieve color classification and generate pseudo-labels, and the pseudo-labels are judged by the semi-supervised prediction monitoring network, and the correctly identified detection frames are retained and the wrong detection frames are filtered out; the correctly identified images are added to the data set, re-input into the Color-RCNN model for training, and the remaining unlabeled images are predicted until all the unlabeled images have obtained reliable labels to achieve semi-supervised learning. It mainly includes the following steps:
[0047] Step 1: Collect images of wooden floors with various colors and defects, mark the color categories of a small number of wooden floors and select the defect locations as marked images, and the rest as unmarked images. Since the defects will affect the color classification when the surface area of the wooden floor is too large, a color corrector based on the combination of grayscale world and perfect reflection is used to correct the color of the wooden floor. The color correction formula based on the combination of grayscale world algorithm and perfect reflection algorithm is as follows:
[0048]
[0049] Among them, R corr represents the R channel correction value considering the defect area and distribution, G corr represents the G channel correction value considering the defect area and distribution, B corr It represents the B channel correction value considering the defect area and distribution, R avg represents the average value of R channel, G avg represents the average value of G channel, B avg Indicates the average value of B channel, R max Indicates the maximum value of R channel, G max Indicates the maximum value of G channel, B max represents the maximum value of channel B, G(f) represents the Fourier transform of the kernel function g(x), g(x) represents the Gaussian kernel function describing the distribution of the defect area, A represents the sum of the defect areas in the wooden floor, x represents the area of a single defect, df represents the integral variable, and the process of Fourier transform and inverse transform is expanded to obtain:
[0050]
[0051] Next, we can combine the exponential terms to get:
[0052]
[0053] Finally, we can take x out of the integral and get:
[0054]
[0055] in, represents the value of the kernel function in the frequency domain, which can be obtained by inverse Fourier transform. When the defect area distribution is more uniform, The value of will be more concentrated in the low frequency part, and vice versa will be more dispersed in the high frequency part. The value of can be used to indicate the influence of defect area distribution on color. In the color correction formula, By convolving or integrating with x, we can get the color correction value that takes into account the influence of the defect area distribution.
[0056] Step 2: Train a Color-RCNN model using labeled images, see Figure 3 , to achieve color classification and defect detection of wooden floors. The specific implementation steps are as follows:
[0057] Step 21: First, input the labeled image and perform data preprocessing;
[0058] Step 22: Pass the processed image into ResNet-101+FPN to obtain the corresponding feature map and extract the input features of the color classifier;
[0059] Step 23: Set ROI for each point in the feature map to obtain multiple ROI candidate boxes;
[0060] Step 24: Send these multiple ROI candidate boxes to RPN for binary classification (foreground or background) and BB regression (Bounding-box regression), and filter out some candidate ROIs;
[0061] Step 25: Perform ROIAlign operation on the remaining ROIs, and use bilinear interpolation to accurately convert each ROI to the same size, first align the pixels of the original image and the feature map, and then align the feature map with the fixed feature;
[0062] Step 26: Input the ROI after Pyramid ROIAlign into the FPN_Classifier network to obtain the classification and BB regression results of each ROI;
[0063] Step 27: Input the ROI that has been Pyramid ROIAligned and the classification and BB regression results of each ROI into the color prediction network to obtain the color classification result;
[0064] Step 28: Combine the color classification results with the target detection results to obtain the final target detection and color classification results, calculate the loss function of target detection and color classification, use the back propagation algorithm to update the network parameters, and repeat steps S21-S28 until the predetermined number of training rounds or convergence is reached.
[0065] Step 3: Take the detection boxes of the labeled images as positive samples, randomly draw boxes on some images as negative samples, build a dataset containing positive and negative samples, and train a semi-supervised prediction monitoring network, see Figure 4, the input is the feature representation of ROI and the category of ROI, and the output is whether the ROI is a reliable pseudo label, judging whether the pseudo label is accurate. The specific implementation steps are as follows:
[0066] Step 31: Take the detection box of the labeled image as the positive sample, and randomly draw the box on the unlabeled image as the negative sample, and construct a data set containing positive and negative samples;
[0067] Step 32: Train the semi-supervised prediction monitoring network and use the positive sample and negative sample data sets for binary classification. After the training, the network can make reliability judgments on the pseudo labels generated by the unlabeled images.
[0068] Step 33: Reliable pseudo labels are screened out through the semi-supervised prediction monitoring network, added to the labeled dataset to retrain Color-RCNN, and the unreliable pseudo labels are used as part of the unlabeled dataset to continue semi-supervised learning.
[0069] Step 4: Use the trained Color-RCNN model to predict the remaining unlabeled images, implement color classification, generate pseudo labels, and use the semi-supervised prediction monitoring network to discriminate the pseudo labels, retain the correctly identified detection frames, and filter out the wrong detection frames;
[0070] Step 5: Combine the filtered unlabeled images with the labeled images, retrain the Color-RCNN model, and predict the remaining unlabeled images until all unlabeled images have reliable labels to achieve semi-supervised learning.
[0071] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for wood floor color classification and defect detection based on semi-supervised multi-task detection, characterized in that: Collect wooden floor images and use the color correction formula based on the combination of gray world algorithm and perfect reflection algorithm to correct the defect color; mark a small number of images as data set input and train the Color-RCNN model improved by Faster-RCNN to achieve color classification and defect detection of wooden floor; use the detection frame in the marked image as a positive sample, and randomly draw frames on the unlabeled image as negative samples, and train the semi-supervised prediction monitoring network designed based on the convolutional neural network to determine whether the pseudo-label is accurate; use the trained Color-RCNN model to predict the remaining unlabeled images, realize color classification, generate pseudo-labels, and use the semi-supervised prediction monitoring network to judge the pseudo-labels, keep the correctly identified detection frames, and filter out the wrong detection frames; add the correctly identified images to the data set, re-input the Color-RCNN model training, and predict the remaining unlabeled images until all unlabeled images have reliable labels, so as to achieve semi-supervised learning, including the following steps: S1: Collect images of wooden floors with various colors and defects, mark the color categories of a small number of wooden floors and select the defect locations as marked images, and use the rest as unmarked images. Since defects may affect the color recognition of wooden floors, the color of wooden floors is corrected according to the defect color correction formula; S2: Use labeled images to train a Color-RCNN model to achieve color classification and defect detection of wooden floors; S3: Take the detection box of the marked image as the positive sample, randomly draw the box on part of the image as the negative sample, build a dataset containing positive and negative samples, train a semi-supervised prediction monitoring network, input the feature representation of ROI and the category of ROI, output whether the ROI is a reliable pseudo label, and judge whether the pseudo label is accurate; S4: Use the trained Color-RCNN model to predict the remaining unlabeled images, implement color classification, generate pseudo labels, and use the semi-supervised prediction monitoring network to discriminate the pseudo labels, retain the correctly identified detection frames, and filter out the wrong detection frames; S5: The filtered unlabeled images are combined with the labeled images, and the Color-RCNN model is retrained to predict the remaining unlabeled images until all unlabeled images have reliable labels, thus achieving semi-supervised learning. In step S1, a color corrector based on the combination of grayscale world and perfect reflection is used to correct the color of the wooden floor. The color correction formula based on the combination of grayscale world algorithm and perfect reflection algorithm is as follows: Among them, R corr represents the R channel correction value considering the defect area and distribution, G corr represents the G channel correction value considering the defect area and distribution, B corr It represents the B channel correction value considering the defect area and distribution, R avg represents the average value of R channel, G avg represents the average value of G channel, B avg Indicates the average value of B channel, R max Indicates the maximum value of R channel, G max Indicates the maximum value of G channel, B max represents the maximum value of channel B, G(f) represents the Fourier transform of the kernel function g(x), g(x) represents the Gaussian kernel function describing the distribution of the defect area, f represents the frequency, A represents the total area of multiple defects in the wooden floor, and x represents the area of a single defect. Expanding the Fourier transform and inverse transform process, we can get: Next, we can combine the exponential terms to get: Finally, we can take x out of the integral and get: in, Represents the value of the kernel function in the frequency domain, which can be obtained by inverse Fourier transform. When the defect area distribution is more uniform, The value will be more concentrated in the low-frequency part, and vice versa, it will be more dispersed in the high-frequency part. The value of can be used to indicate the influence of defect area distribution on color. In the color correction formula, By convolving or integrating with x, we can get the color correction value that takes into account the influence of the defect area distribution.
2. The method for wood floor color classification and defect detection based on semi-supervised multi-task detection according to claim 1 is characterized in that: In step S2, a Color-RCNN model improved based on Faster-RCNN uses a color prediction network for color classification, the network includes a convolutional layer and a fully connected layer, the input is the ROI (region of interest) of the defect area output by PyramidROIAlign and the output result of the FPN_Classifier network, the output is the color classification result, the FPN_Classifier network is cascaded with the color prediction network, and then the classification and BB regression results of the ROI output by the FPN_Classifier network are input into the color prediction network, so that it can perform target detection and color classification at the same time.
3. The method for wood floor color classification and defect detection based on semi-supervised multi-task detection according to claim 1 is characterized in that: The step S2 comprises the following steps: S21: First, input the labeled image and perform data preprocessing; S22: Pass the processed image into ResNet-101+FPN to obtain the corresponding feature map and extract the input features of the color classifier; S23: Setting ROI for each point in the feature map to obtain multiple ROI candidate boxes; S24: Send these multiple ROI candidate boxes to RPN for binary classification into foreground or background and BB regression (Bounding-box regression), and filter out some candidate ROIs; S25: Perform ROIAlign operation on the remaining ROIs, use bilinear interpolation to accurately convert each ROI to the same size, first match the pixels of the original image and the feature map, and then match the feature map with the fixed feature; S26: Input the ROI after Pyramid ROIAlign into the FPN_Classifier network to obtain the classification and BB regression results of each ROI; S27: Input the ROI after Pyramid ROI Align and the classification and BB regression results of each ROI into the color prediction network to obtain the color classification result; S28: Combine the color classification results with the target detection results to obtain the final target detection and color classification results, calculate the loss function of target detection and color classification, use the back propagation algorithm to update the network parameters, and repeat steps S21-S28 until the predetermined number of training rounds or convergence is reached.
4. The method for wood floor color classification and defect detection based on semi-supervised multi-task detection according to claim 1 is characterized in that: The step S3 comprises the following steps: S31: Take the detection box of the labeled image as the positive sample, and randomly draw the box on the unlabeled image as the negative sample, and construct a data set containing positive and negative samples; S32: Train the semi-supervised prediction monitoring network and use the positive sample and negative sample data sets for binary classification. After the training, the network can make reliability judgments on the pseudo labels generated by the unlabeled images. S33: Reliable pseudo labels are screened out through the semi-supervised prediction monitoring network and added to the labeled dataset to retrain Color-RCNN. The unreliable pseudo labels are used as part of the unlabeled dataset to continue semi-supervised learning.
5. The method for wood floor color classification and defect detection based on semi-supervised multi-task detection according to claim 1 is characterized in that: The structure of the semi-supervised prediction monitoring network includes a convolution layer, a pooling layer and a fully connected layer, wherein the convolution layer 1 uses 32 3x3 convolution kernels with a step size of 1 and a ReLU activation function to input image data and extract image features. The pooling layer 1 uses a 2x2 maximum pooling kernel with a step size of 2 to perform downsampling and reduce the size of the feature map. The convolution layer 2 uses the result of the pooling layer 1 as input to extract higher-level features. The convolution layer 2 uses 64 3x3 convolution kernels with a step size of 1 and a ReLU activation function. The pooling layer 2 uses a 2x2 maximum pooling kernel with a step size of 2 to perform downsampling and reduce the size of the feature map. The convolution layer 3 uses the result of the pooling layer 2 as input and then Continue to extract high-level features. Convolution layer 3 uses 128 3x3 convolution kernels with a step size of 1 and a ReLU activation function. Pooling layer 3 uses a 2x2 maximum pooling kernel with a step size of 2 for downsampling to reduce the size of the feature map. After a fully connected layer 1, the feature map is expanded into a one-dimensional vector and fully connected. There are 256 neurons in total and the ReLU activation function is used. After a Dropout layer, 50% of the neurons are randomly discarded to reduce overfitting. Finally, after a fully connected layer 2 as the output layer, the Sigmoid activation function is used to classify the pseudo-labels into two categories. The output is 0 for an incorrect pseudo-label and 1 for a correct pseudo-label.
Citation Information
Cited By
Semi-supervised wood defect detection method based on generative adversarial network
CN119251584A
