Chopstick defect detection method and system based on transfer learning

Through the chopstick defect detection method based on transfer learning, the six-category deep learning network and image super-resolution enhancement processing are used to solve the accuracy and resource consumption problems of chopstick defect detection in the existing technology, and achieve high accuracy of chopstick surface defects. and reliability testing.

CN114004829BActive Publication Date: 2024-09-24SHAOYANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111396120.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-23
Publication Date
2024-09-24
Estimated Expiration
2041-11-23

AI Technical Summary

Technical Problem

Existing chopstick defect detection methods have problems such as inaccurate artificial feature recognition, the depth of the network level affecting the recognition accuracy and time delay, and the small scale of the chopstick image affecting surface feature extraction, making it difficult to detect multiple types of surface defects.

Method used

Using the chopstick defect detection method based on transfer learning, the original image of the chopsticks and the background image are binarized and filtered by difference, then the six-class deep learning network model is input, and the variance of the classification output probability value is calculated to determine whether image super-resolution enhancement is needed. processing, thereby improving detection accuracy and reliability.

Benefits of technology

It achieves precise detection of chopstick surface defects, reduces data set production costs, improves detection accuracy and reliability, and saves system software and hardware resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114004829B
    Figure CN114004829B
Patent Text Reader

Abstract

The present invention relates to the technical field of image recognition and deep learning, and discloses a chopstick defect detection method and system based on transfer learning to improve the reliability of the detection result. The method comprises: obtaining a first chopstick image by subtracting a collected original chopstick image from a background image; inputting the first chopstick image into a trained six-classification deep learning network model to obtain the probability values ​​of the first chopstick image output corresponding to the six classifications; calculating the variance between the probability values ​​of the outputs of each classification, judging whether the variance is less than or equal to a set threshold, and if the judgment result is no, directly taking the label corresponding to the highest probability value as the final classification result; if the judgment result is yes, performing image super-resolution enhancement processing on the first chopstick image to obtain a second chopstick image, and then inputting the second chopstick image into the six-classification deep learning network model to take the label corresponding to the highest probability value in the six classifications as the final classification result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image recognition and deep learning technology, and in particular to a chopstick defect detection method and system based on transfer learning. Background Art

[0002] In the field of chopstick production, surface defects of chopsticks directly affect their appearance, performance and other properties. Especially in export-earning products, the surface quality of chopsticks is crucial. Traditional chopstick defect detection generally relies on human visual observation to determine whether there are defects. This detection method is time-consuming and prone to human detection errors when workers are tired.

[0003] With the advancement of science and technology, machine detection methods have been greatly developed and have gradually replaced manual detection. Existing machine detection technologies are divided into defect detection methods based on template matching and defect detection methods based on deep learning.

[0004] Specifically, the chopstick surface defect detection method based on template matching is as follows: Figure 1 As shown in the figure, the chopsticks image is generally preprocessed, and then the artificial customized features are extracted for modeling, and the defects are detected by template matching. Since the surface defects of chopsticks are of various types and shapes, this method cannot detect defects other than the matching template, and the error is large. The current chopstick surface defect detection method based on deep learning is as follows: Figure 2 As shown, it is possible to automatically extract abstract features and learn more abstract expressions of chopstick images. However, the existing methods can usually only detect whether there are defects on the surface of chopsticks. The detection accuracy is closely related to the level of the neural network. The deeper the network level, the higher the detection accuracy, the more difficult it is to converge during training, and the real-time performance will also deteriorate.

[0005] The present invention is made to solve the common problems in the field, such as artificial features cannot identify new samples, the depth of network layers will affect the recognition accuracy and delay, and the small scale of chopstick images will affect the extraction of surface features. Summary of the invention

[0006] The present invention aims to disclose a chopstick defect detection method and system based on transfer learning to improve the reliability of the detection results.

[0007] To achieve the above object, the present invention discloses a chopstick defect detection method based on transfer learning, comprising:

[0008] Collect the original image of chopsticks;

[0009] Binarize the foreground image obtained by subtracting the original chopstick image from the background image, and locate and extract the first chopstick image to be detected after filtering;

[0010] Inputting the first chopstick image into a trained six-category deep learning network model, wherein the six categories of the six-category deep learning network model include: normal, burr, spot, concave hole, whitening and crack; obtaining the probability values ​​of the first chopstick image output corresponding to the six categories;

[0011] Calculate the variance between the probability values ​​output by each classification, and determine whether the variance is less than or equal to a set threshold. If the determination result is no, directly use the label corresponding to the highest probability value as the final classification result; if the determination result is yes, perform image super-resolution enhancement processing on the first chopstick image to obtain a second chopstick image, and then input the second chopstick image into the six-classification deep learning network model, and use the label corresponding to the highest probability value in the six classes as the final classification result;

[0012] The acquisition of the six-category deep learning network model includes:

[0013] Use common datasets to pre-train deep learning network models;

[0014] A six-category dataset is constructed for the training images, and the pre-trained deep learning network model is trained again using the constructed six-category dataset to obtain the six-category deep learning network model.

[0015] Preferably, in the process of obtaining the second chopstick image after performing image super-resolution enhancement processing on the first chopstick image, the super-resolution model based on CNN is trained using a stochastic gradient descent method, which specifically includes:

[0016] First, the original image is downsampled with a preset scaling factor r to form an LR image I LR , and then crop the LR image into a set of f sub ×f sub The sub-image of pixel size, the HR sub-image I corresponding to the LR image HR is cropped from the original image and has a size of r 2 ×f sub ×f sub Pixel, I LR with I HR The sub-images are paired to form training data; the super-resolution network used for image super-resolution enhancement processing consists of three parts: feature extraction, nonlinear mapping and image reconstruction. The back propagation algorithm is used for training, and the training parameters are Θ = {W1, W2, ... W m ,B1,B2,…B m},W m is the network weight, B m is the network bias, m is the number of network layers, and the loss function uses MSE. The loss function is as follows:

[0017]

[0018] Where n is the number of samples, Represents the reconstructed image obtained after the low-resolution image passes through the enhancement network. Represents the original high-resolution image.

[0019] Preferably, the background image of the present invention is de-noised by a time averaging method, and the time averaging method is:

[0020]

[0021]

[0022] Among them, p t is the background image at different times, w i is the weight parameter, n is the number of background images;

[0023] Correspondingly, in the process of constructing the six-category dataset for the training images, the original training image samples are transformed by brightness transformation to expand the sample training set.

[0024] To achieve the above objectives, the present invention also discloses a chopstick defect detection system based on transfer learning, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0025] The present invention has the following beneficial effects:

[0026] 1. Subtracting the collected original image of chopsticks from the background image can achieve accurate collection of chopstick images at any position.

[0027] 2. The six-classification deep learning network model adopts the method of transfer learning. It first pre-trains the deep network with a general data set, and then trains the deep network with a customized data set. This can reduce the samples of the customized data set, accelerate the convergence of the deep network, and greatly save the labor cost of data set production. It is more accurate than using artificial customized features to detect surface defects of chopsticks, and is more accurate and reliable than the detection of a single deep network (i.e., defective and non-defective).

[0028] 3. The original image of chopsticks and the first image of chopsticks contain fewer pixels, which is not conducive to the recognition of surface defects of chopsticks. Therefore, the variance of the six-category output scores is calculated. If the variance is less than the specified threshold, it means that the probability of classification error is high. By further performing super-resolution enhancement on the first chopstick image to obtain the second chopstick image and then sending it to the six-category deep learning network model again, the recognition rate of surface defects of chopsticks is improved, and accurate classification of chopsticks can be obtained.

[0029] 4. The first chopstick image that needs to be enhanced is screened by comparing the variance between the probability values ​​of each classification output with the set threshold. Compared with performing image enhancement on each first chopstick image, the computational complexity of data processing is greatly reduced while ensuring the reliability of the results, which greatly saves the system's software and hardware resources.

[0030] The present invention will be further described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The drawings constituting a part of this application are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0032] Figure 1 The figure is a schematic diagram of the defect detection process of the prior art.

[0033] Figure 2 The figure is a flow chart of the surface defect detection method based on deep learning in the prior art.

[0034] Figure 3 4 is a simplified flow chart of a method for detecting surface defects of chopsticks according to an embodiment of the present invention.

[0035] Figure 4 The figure is a schematic diagram of the chopstick image positioning and extraction process according to an embodiment of the present invention.

[0036] Figure 5 A schematic diagram of the process of deep learning network model training according to an embodiment of the present invention.

[0037] Figure 6 This is a schematic diagram of the deep learning network model structure of an embodiment of the present invention.

[0038] Figure 7 Schematic diagram of the super-resolution network model structure of an embodiment of the present invention. DETAILED DESCRIPTION

[0039] The embodiments of the present invention are described in detail below with reference to the accompanying drawings, but the present invention can be implemented in many different ways as defined and covered by the claims.

[0040] Example 1

[0041] The embodiment of the present invention discloses a chopstick defect detection method based on transfer learning. Figure 3 As shown, the specific steps include:

[0042] Step S1, collecting the original image of chopsticks.

[0043] Step S2: binarize the foreground image obtained by subtracting the original chopstick image from the background image, and locate and extract the first chopstick image to be detected after filtering.

[0044] In this step, optionally, the first chopstick image is located and extracted as follows: Figure 4 As shown in the figure: the first chopstick image is obtained by subtracting the original image of chopsticks from the background image, binarizing the difference image, and performing morphological filtering. The original image of chopsticks is the image of chopsticks taken by a fixed camera on the chopstick production line, and the background image is the image of the machine taken by a fixed camera on the production line when chopsticks are not being produced.

[0045] Preferably, this embodiment takes into account that during the production process, the collected images are susceptible to changes in the lighting environment. Among them, the main uncontrollable component that causes the change in the lighting environment is sunlight. For this reason, the background image of this embodiment is de-noised by a time averaging method, and the time averaging method is:

[0046]

[0047]

[0048] Among them, p t is the background image at different times, w i is the weight parameter, and n is the number of background images.

[0049] Step S3, input the first chopstick image into a trained six-category deep learning network model, wherein the six categories of the six-category deep learning network model include: normal, burr, spot, concave hole, tender white and crack; obtain the probability values ​​of the first chopstick image in the six categories. The so-called "tender white" means that the bamboo is tender and white in color; this type of chopsticks is classified as a defect because it is easy to break.

[0050] In this step, if Figure 5 As shown, the acquisition of the six-category deep learning network model includes:

[0051] Step S31, pre-training the deep learning network model using a general data set. Optionally, the general data set generally uses an existing multi-classification data set, such as a MINST data set. An initial six-classification deep learning network model can be obtained through pre-training.

[0052] Step S32, construct a six-category dataset for the training image, and then use the constructed six-category dataset to retrain the pre-trained deep learning network model to obtain a precisely optimized six-category deep learning network model. Corresponding to the above-mentioned time averaging method for background image optimization, in this step, in the process of constructing the six-category dataset for the training image, the original training image samples are transformed by brightness transformation to expand the sample training set.

[0053] In the process of customizing the multi-classification chopstick sample training set, the multi-classification chopstick data set includes 5 types of defective chopstick training sample images, which are respectively divided into burrs, spots, concave holes, whitening, and cracks, and are annotated separately; the multi-classification chopstick data set also includes multiple non-defective chopstick training sample images, which are annotated separately. And it also includes: scaling the original training sample chopstick images to make them conform to the end-to-end deep network input interface.

[0054] In this embodiment, the deep learning network model adopts a multi-classification deep network, whose structure is as follows: Figure 6 As shown. The multi-classification deep network is composed of multiple convolutional layers, pooling layers, fully connected layers and output layers. In the last convolutional layer, the fully connected layer is deformed, and the fully connected layer is sparsely connected to obtain 6 major output categories, namely burrs, spots, pits, whitening, cracks and no defects. Preferably, the multi-classification deep network is trained by stochastic gradient descent. The corresponding error function adopts the cross entropy function, which is:

[0055]

[0056] Wherein, y is the real output, f(x i ; θ) is the network prediction output, n is the number of samples, and θ is the deep network parameter.

[0057] Step S4, calculate the variance between the output probability values ​​of each classification, and determine whether the variance is less than or equal to the set threshold. If the judgment result is no, directly use the label corresponding to the highest probability value as the final classification result; if the judgment result is yes, perform image super-resolution enhancement processing on the first chopstick image to obtain a second chopstick image, and then input the second chopstick image into the six-classification deep learning network model, and use the label corresponding to the highest probability value in the six categories as the final classification result.

[0058] In this step, optionally, since the original image of the chopsticks contains fewer pixels, which is not conducive to the recognition of surface defects of the chopsticks, the detail features of the chopsticks image can be enhanced through a super-resolution network. Figure 7As shown, it consists of three parts: feature extraction, nonlinear mapping and image reconstruction. Feature extraction is to perform convolution on the low-resolution image Y that has been interpolated, and extract multi-dimensional feature vectors to form a feature mapping matrix; nonlinear mapping is to map the extracted n1-dimensional features to n2-dimensional features through nonlinear convolution operations; image reconstruction is equivalent to a deconvolution process, which performs mean filtering on the n2-dimensional nonlinear features to generate a high-resolution image. Specifically, in the process of obtaining the second chopstick image after performing image super-resolution enhancement processing on the first chopstick image, the CNN-based super-resolution model is trained using the stochastic gradient descent method, including:

[0059] First, the original image is downsampled with a preset scaling factor r to form an LR image I LR , and then crop the LR image into a set of f sub ×f sub The sub-image of pixel size, the HR sub-image I corresponding to the LR image HR is cropped from the original image and has a size of r 2 ×f sub ×f sub Pixel, I LR with I HR The sub-images are paired to form training data; the super-resolution network used for image super-resolution enhancement processing consists of three parts: feature extraction, nonlinear mapping and image reconstruction. The back propagation algorithm is used for training, and the training parameters are Θ = {W1, W2, ... W m ,B1,B2,…B m},W m is the network weight, B m is the network bias, m is the number of network layers, and the loss function uses MSE. The loss function is as follows:

[0060]

[0061] Where n is the number of samples, Represents the reconstructed image obtained after the low-resolution image passes through the enhancement network. Represents the original high-resolution image.

[0062] In this step, considering that super-resolution enhancement of each first chopstick image will increase network latency, an improved method is adopted to obtain the real chopstick image by subtracting the acquired chopstick image to be detected from the background image obtained by pre-modeling, and then scale it and directly send it to the offline trained 6-category deep network model to obtain the normalized scores of the 6-category output of chopsticks. The calculation formula is as follows:

[0063]

[0064] Where X is the input chopstick image, θ is the deep network parameter, and f i (X; θ) is the output of the chopstick image through the 6-category deep network, i=1…6 is the number of output results, and the one with the highest score is the true classification of chopsticks. max(S) is the maximum value of the 6-category output results. The normalization operation is to divide by the maximum value of the 6-category output results to avoid increasing the amount of calculation due to excessive calculation results. After that, the variance of the 6-category output normalized scores is calculated. If the variance is less than the specified threshold, it means that the probability of classification error is high. At this time, super-resolution enhancement is performed on the real chopstick image and it is sent to the multi-classification deep network again to obtain the accurate classification of chopsticks. The variance calculation formula of the 6-category output normalized scores is as follows:

[0065]

[0066] Among them, S is the normalized score of the 6-category output, is the mean.

[0067] In summary, the method of this embodiment has the following beneficial effects:

[0068] 1. Subtracting the collected original image of chopsticks from the background image can achieve accurate collection of chopstick images at any position.

[0069] 2. The six-classification deep learning network model adopts the method of transfer learning. It first pre-trains the deep network with a general data set, and then trains the deep network with a customized data set. This can reduce the samples of the customized data set, accelerate the convergence of the deep network, and greatly save the labor cost of data set production. It is more accurate than using artificial customized features to detect surface defects of chopsticks, and is more accurate and reliable than the detection of a single deep network (i.e., defective and non-defective).

[0070] 3. The original image of chopsticks and the first image of chopsticks contain fewer pixels, which is not conducive to the recognition of surface defects of chopsticks. Therefore, the variance of the six-category output scores is calculated. If the variance is less than the specified threshold, it means that the probability of classification error is high. By further performing super-resolution enhancement on the first chopstick image to obtain the second chopstick image and then sending it to the six-category deep learning network model again, the recognition rate of surface defects of chopsticks is improved, and accurate classification of chopsticks can be obtained.

[0071] 4. The first chopstick image that needs to be enhanced is screened by comparing the variance between the probability values ​​of each classification output with the set threshold. Compared with performing image enhancement on each first chopstick image, the computational complexity of data processing is greatly reduced while ensuring the reliability of the results, which greatly saves the system's software and hardware resources.

[0072] Example 2

[0073] Corresponding to the above-mentioned embodiments, this embodiment discloses a chopstick defect detection system based on transfer learning, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps corresponding to the above-mentioned method embodiments when executing the computer program.

[0074] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A chopstick defect detection method based on transfer learning, characterized in that: include: Collect the original image of chopsticks; Binarize the foreground image obtained by subtracting the original chopstick image from the background image, and locate and extract the first chopstick image to be detected after filtering; Inputting the first chopstick image into a trained six-category deep learning network model, wherein the six categories of the six-category deep learning network model include: normal, burr, spot, concave hole, whitening and crack; obtaining the probability values ​​of the first chopstick image output corresponding to the six categories; Calculate the variance between the probability values ​​output by each classification, and determine whether the variance is less than or equal to a set threshold. If the determination result is no, directly use the label corresponding to the highest probability value as the final classification result; if the determination result is yes, perform image super-resolution enhancement processing on the first chopstick image to obtain a second chopstick image, and then input the second chopstick image into the six-classification deep learning network model, and use the label corresponding to the highest probability value in the six classes as the final classification result; The acquisition of the six-category deep learning network model includes: Use common datasets to pre-train deep learning network models; A six-category dataset is constructed for the training images, and the pre-trained deep learning network model is trained again using the constructed six-category dataset to obtain the six-category deep learning network model.

2. The method according to claim 1, characterized in that In the process of obtaining the second chopstick image by performing image super-resolution enhancement processing on the first chopstick image, the super-resolution model based on CNN is trained by adopting the stochastic gradient descent method, which specifically includes: First, the original image is downsampled with a preset scaling factor r to form an LR image I LR , and then crop the LR image into a set of f sub ×f sub The sub-image of pixel size, the HR sub-image I corresponding to the LR image HR is cropped from the original image and has a size of r 2 ×f sub ×f sub Pixel, I LR with I HR The sub-images are paired to form training data; the super-resolution network used for image super-resolution enhancement processing consists of three parts: feature extraction, nonlinear mapping and image reconstruction. The back propagation algorithm is used for training, and the training parameters are Θ = {W1, W2, ... W m ,B1,B2,…B m },W m is the network weight, B m is the network bias, m is the number of network layers, and the loss function uses MSE. The loss function is as follows: Where n is the number of samples, Represents the reconstructed image obtained after the low-resolution image passes through the enhancement network. Represents the original high-resolution image.

3. The method according to claim 1 or 2, characterized in that: The background image is de-noised by a time averaging method, and the time averaging method is: Among them, p t is the background image at different times, w i is the weight parameter, n is the number of background images; Correspondingly, in the process of constructing the six-category dataset for the training images, the original training image samples are transformed by brightness transformation to expand the sample training set.

4. A chopstick defect detection system based on transfer learning, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.