A method for detecting defects from inconsistent labels
Through the combination of rough set theory and Bayesian neural network, the uncertainty model and scoring network are established, which solves the problem of model instability caused by inconsistent labels in surface defect detection, and achieves high-accuracy and interpretable detection results. , improving the consistency of product quality.
Patent Information
- Application Number
- CN202210454583.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-27
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-04-27
AI Technical Summary
In existing deep learning models, inconsistent labels lead to model instability and poor consistency in surface defect detection, resulting in uneven product quality. Moreover, existing methods mainly focus on image-level labels rather than pixel-level labels, and cannot effectively handle industrial inspections. common transition areas and weak feature areas.
Rough set theory is used to establish an uncertainty model and a scoring Bayesian neural network is constructed. Through the combination of Bayesian segmentation network and scoring network, multiple solutions and iterative training are performed to generate an abnormal segmentation probability map, and the confidence threshold is used to determine whether Provides interpretable inspection results in the presence of surface defects.
Without increasing labeling costs, it achieves high segmentation accuracy and detection results close to the actual situation, provides interpretability judgment indicators, can effectively deal with model uncertainty caused by inconsistent labels, and improves the consistency of product quality. sex.
Smart Images

Figure CN114972194B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field related to image processing, and more specifically, relates to a method for detecting defects from inconsistent labels. Background Art
[0002] As an essential step in the manufacturing process, surface defect detection is widely used in various industrial fields, including semiconductor electronics, automobiles, medicine, chemicals, etc. Deep learning has achieved very good results in the field of surface defect detection.
[0003] However, as a data-driven model, deep convolutional neural networks can in some cases reproduce or amplify human errors and biases introduced into the training dataset during data collection and annotation. This problem not only occurs in natural and medical data, but is even more serious in surface defect detection.
[0004] The surface defect detection task mainly faces the following challenges in the image labeling task: First, the edge of the abnormal area is not an ideal line, but an area; second, due to the low contrast between the defect and the background, and the small area of the abnormal area, there are some areas with weak features. Transition areas and weak feature areas can neither be accurately classified as abnormal nor as normal. In addition, the labeling of suspected areas is easily affected by factors such as workers' emotional fluctuations, technical level, judgment standards, and individual differences, resulting in poor label consistency. This is reflected in the image that some of the boundaries of the abnormal areas have a smaller marking range, some have a larger marking range, and even some areas are not marked.
[0005] However, the geometric size of the abnormal area (such as length or diameter) is a necessary indicator to determine whether the abnormality is a defect. Inconsistent labels affect the stability and consistency of the model, which ultimately causes product quality to fluctuate and become uneven, causing irreparable losses.
[0006] For inconsistent labels, existing methods can be divided into methods based on Bayesian probability estimation, methods based on label proxy, and methods based on "divide and conquer". However, these methods are all based on multi-labeling (multiple labeling of the same sample), which not only increases labor costs, but also the labels are at the image level. For surface defect detection, we should focus on pixel-level labels rather than image-level labels.
[0007] At the pixel level, SEAL and STEAL proposed label alignment schemes based on prior knowledge. SEAL transforms the problem of accurate edge optimization into a bipartite graph cost allocation problem. Based on biased Gaussian kernels and Markov priors, labels are continuously corrected during training to ultimately obtain accurate edges. STEAL proposed new layers and losses, taking the normal direction of edge pixels for non-maximum suppression, and using normal consistency loss to achieve accurate edge extraction. However, these methods all assume the existence of ideal edges. In industrial inspection, from the analysis of defect causes, there are transition areas, and the assumption of the existence of ideal edges is often not valid. In addition, some weak feature areas may even be ignored and not marked. Therefore, it is not enough to focus only on the edges in the labels.
[0008] The challenges of manual labeling are objective, and model inconsistency caused by inconsistent labels is inevitable. Using purely mathematical assumptions to eliminate or avoid this uncertainty is often not ideal. On the contrary, if we face it and process this information appropriately, it often helps solve practical problems.
[0009] Therefore, there is an urgent need in this field to propose a method for learning a defect detection model from inconsistent labels, to face up to the model uncertainty caused by inconsistent labels, to establish an uncertainty model, to solve and ultimately obtain consistent and explainable detection results. Summary of the invention
[0010] In response to the above defects or improvement needs of the prior art, the present invention provides a method for detecting defects from inconsistent labels, which can learn consistent and interpretable detection results from inconsistent labels. The proposed uncertainty model provides a suitable processing idea for the inconsistent factors in the labels, the proposed scoring Bayesian neural network provides an uncertainty solution method, and the proposed confidence solution method provides an interpretable indicator with high segmentation accuracy and detection results close to the actual situation.
[0011] To achieve the above object, according to one aspect of the present invention, a method for detecting defects from inconsistent labels is provided, the method comprising the following steps:
[0012] (1) Abnormal areas of industrial images are labeled at the pixel level to obtain labels that may be inconsistent. The resulting dataset is divided into a training set and a test set.
[0013] (2) Based on the rough set theory, a label uncertainty model is established. The area in the image that is determined to be abnormal is divided into a certain area, whose boundary is the supremum; the area suspected to be abnormal is divided into a suspected area, whose boundary is the infimum, and the area between the supremum and the infimum is the uncertain area;
[0014] (3) constructing a scoring Bayesian neural network, wherein the scoring Bayesian neural network includes a Bayesian segmentation network and a scoring network, training the scoring Bayesian neural network using a training set to obtain a parameterized model of the scoring Bayesian neural network, and evaluating the scoring Bayesian neural network using a test set to obtain an optimal parameterized model of the scoring Bayesian neural network;
[0015] (4) Inputting the sample to be detected into the Bayesian segmentation network, solving multiple times to obtain multiple abnormal segmentation maps, inputting the multiple abnormal segmentation maps together with the corresponding images into the scoring network to obtain multiple quality evaluation scores, and multiplying the abnormal segmentation map with the corresponding quality evaluation score to obtain the final abnormal segmentation probability map;
[0016] (5) Determine the defect threshold and confidence threshold according to actual production needs, obtain the confidence based on the defect threshold and the abnormal segmentation probability map, compare the obtained confidence with the confidence threshold, and determine whether there is a surface defect based on the comparison result.
[0017] Furthermore, for a pair of non-empty sets Ω = (U, A), where U is the set of all pixels in the image and A is the set of all features of the pixels; any subset B of A determines an indistinguishability relation I(B), the image region determined by the subset B is denoted as U / B, and the pixel x belongs to U / B and is denoted as B(p). In the abnormal region In the definition, the lower approximation is B * (X), the upper approximation is B * (X), the corresponding expressions are:
[0018]
[0019]
[0020] The uncertainty areas are:
[0021] BN B (X) = B * (X)-B * (X).
[0022] Furthermore, the images in the training set are input into the Bayesian segmentation network for multiple solutions to obtain multiple abnormal segmentation maps, and the multiple abnormal segmentation maps obtained are compared with the labels respectively to obtain multiple segmentation errors; the images and labels in the training set are input into the scoring network together to obtain the quality evaluation score of the label, and then the mean of the obtained segmentation errors and the corresponding quality evaluation score are used as the segmentation loss for iterative training of the Bayesian segmentation network to obtain a parameterized model of the Bayesian segmentation network.
[0023] Furthermore, the variance of the segmentation error is used to calculate the label of the quality evaluation score, and the quality evaluation score is compared with the label of the quality evaluation score to obtain the scoring loss and used for iterative training of the scoring network, thereby obtaining a parameterized model of the scoring network.
[0024] Furthermore, the Bayesian segmentation network is composed of an encoder, an intermediate layer, and a decoder connected end to end; the Bayesian segmentation network is composed of an encoder, an intermediate layer, and a decoder connected end to end; wherein the encoder includes several downsamplings and several layers of spatially related Bayesian neural network modules; the intermediate layer is composed of several layers of spatially related Bayesian neural network modules; the decoder includes several layers of upsampling layers; the spatially related Bayesian convolutional neural network module includes a convolutional layer, a spatial Dropout layer, and a batch normalization layer connected in sequence; the scoring network is composed of several downsamplings, and the last layer is a global maximum pooling layer;
[0025] The scoring network consists of several downsampling layers, and the last layer is a global maximum pooling layer.
[0026] Furthermore, the training of the Bayesian segmentation network and the scoring network includes the following steps:
[0027] (1) The training set samples {x1,...,x N} and labels {y1,...,y N} Input the Bayesian segmentation network and get the i-th th Multiple segmentation results of samples Compare the segmentation results and labels to obtain the cross entropy loss Bce Loss and the set similarity loss Dice Loss. Combine Bce Loss and Dice Loss to get the segmentation error Seg error.
[0028] (2) The training set samples {x1,...,x N} and labels {y1,...,y N} Input the scoring network and get the corresponding quality evaluation score {s1,...,s N};
[0029] (3) Mean of segmentation error i and the corresponding quality evaluation scores {s1,...,s N} multiplied as segmentation loss Loss seg , and use this to iteratively train the Bayesian segmentation network to obtain a parameterized model of the Bayesian segmentation network;
[0030] (4) The variance of the segmentation error Var iMake a label ls for the quality evaluation score i ;
[0031] (5) The label quality evaluation scores {s1,...,s N} and the label ls of the quality evaluation score i Compare and get the score loss Loss score It is used for iterative training of the scoring network to obtain a parameterized model of the scoring network.
[0032] Furthermore, the cross entropy loss Bce Loss is:
[0033]
[0034] V represents the segmented abnormal area, and the set similarity loss Dice Loss is:
[0035]
[0036] Furthermore, λ represents a trade-off hyperparameter for controlling the relative importance of these two items, and λ>0, the segmentation error Seg error is:
[0037]
[0038] The mean of the segmentation error Seg error i and variance Var i They are:
[0039]
[0040]
[0041] Furthermore, the training set samples {x1,...,x N} and labels {y1,...,y N} Input the scoring network and get the corresponding quality evaluation score {s1,...,s N}, the segmentation loss Loss seg for:
[0042]
[0043] The labels for the quality assessment scores are:
[0044]
[0045] The scoring loss of the evaluation network is:
[0046]
[0047] Furthermore, obtaining the abnormal probability segmentation map includes the following steps:
[0048] Step 1: Collect the image x to be detected * , input the optimal parameter model, and solve k through the Bayesian segmentation network th Second, get the segmentation result
[0049] Step 2: Transform the image x * And the segmentation result Input the scoring network to get the corresponding score
[0050] Step 3: Multiply the abnormal segmentation map with the corresponding quality evaluation score and obtain the final abnormal segmentation probability map p(x * ).
[0051] Furthermore, the abnormal segmentation probability map p(x * )for:
[0052]
[0053] Furthermore, determining whether an anomaly is a defect includes the following steps:
[0054] Step 1: According to the actual production needs, the defect threshold T representing whether an abnormality can be judged as a defect is usually set according to national standards, industry standards or factory standards;
[0055] Step 2: Based on the defect threshold T and the abnormal segmentation probability map p(x * ) to obtain the confidence
[0056] Step 3: Set the confidence threshold according to the factory's quality requirements. If the confidence is greater than or equal to the confidence threshold, it is judged as NG; if it is less than the confidence threshold, it is judged as OK.
[0057] Furthermore, c is determined to be in the range of [0,1], when c - = 0, we get the lower bound, when c + =1, obtain the supremum; GD is the geometric size of the abnormal area, y is the value of each pixel in the image;
[0058]
[0059] Then the confidence level is:
[0060]
[0061] Among them, g -1 (T) is the inverse function of g(T).
[0062] In general, compared with the prior art, the method for detecting defects from inconsistent labels provided by the present invention has the following beneficial effects:
[0063] 1. The method uses only samples and inconsistent labels as training sets. Without increasing the labeling cost, it can obtain anomaly segmentation probability maps and calculate the confidence that anomalies can be identified as defects, providing an interpretable basis.
[0064] 2. An uncertainty model of defect detection is established based on rough sets, which provides a reasonable representation for inconsistent labels caused by human factors.
[0065] 3. Through spatial Dropout, continuous Bernoulli distribution is used to simulate Gaussian distribution. Without adding any network parameters, a Bayesian neural network is constructed to obtain the abnormal segmentation probability map. Through spatial Dropout, the contextual relationship of the image is retained, the network structure is reasonably designed, and a specific combination is performed to achieve higher segmentation accuracy.
[0066] 4. A scoring network is introduced to score the label quality, which provides a reliable anomaly segmentation model by making full use of labels with poor consistency or even noisy labels without increasing the data and label costs.
[0067] 5. The confidence evaluation index has physical meaning and provides an explainable basis for judgment. In practical applications, factories can determine the confidence threshold according to actual needs to obtain consistent judgment results.
[0068] 6. The automatic memory adversarial autoencoder model is constructed under 8G memory and a GPU of NVIDIA GeForce GTX 1070. The defect detection method provided by the present invention can reach 67.11FPS. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 It is a flow chart of a method for detecting defects from inconsistent labels provided by the present invention;
[0070] Figure 2 (a) and (b) are schematic diagrams of establishing the uncertainty model of labels based on rough set theory;
[0071] Figure 3 It is a flowchart of the training and testing of the scoring Bayesian neural network;
[0072] Figure 4 It is a schematic diagram of abnormal segmentation areas with different confidence levels;
[0073] Figure 5 (1) to (3) are three sets of data sets in Example 1 of the present invention, (a)-(b) are inclusion defects, (c)-(d) are patches defects, and (e)-(f) are scratches defects. DETAILED DESCRIPTION
[0074] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0075] See also Figure 1 , Figure 2 , Figure 3 and Figure 4 The present invention provides a method for detecting defects from inconsistent labels, which is used to detect unqualified workpieces with abnormal performance in the industrial manufacturing process. It mainly solves the problem that in the image labeling process, the labeling of edges and weak feature areas is easily affected by factors such as workers' emotional fluctuations, technical levels, judgment standards, and individual differences, resulting in poor label consistency, which in turn leads to uncertain results of the model and uneven product quality. The present invention establishes an uncertainty model based on rough set theory to characterize inconsistent information in labels, solves the uncertainty model through Bayesian neural network, and finally gives a confidence evaluation index, and uses confidence as a judgment basis to obtain products with good consistency. The method collects images from industrial sites, completes labeling, and obtains labels that may be inconsistent; establishes an uncertainty model of labels based on rough set theory, constructs a scoring Bayesian neural network for surface defect detection, learns a parameterized model from inconsistent labels, and uses a training set for training and a test set for evaluation to obtain the optimal parameterized model; sets defect discrimination confidence to measure the uncertainty of whether an abnormality can be judged as a defect. During online detection, the image to be detected is collected, and the abnormal segmentation probability map is obtained through the scoring Bayesian neural network. The defect threshold is determined according to actual needs, and the confidence is obtained according to the defect threshold and the abnormal segmentation probability. The confidence threshold is set according to product quality requirements. If the confidence is greater than or equal to the confidence threshold, it is judged as NG, otherwise it is OK. Without increasing the labeling cost, the present invention is not only superior to the existing technology in abnormal segmentation, but also obtains a defect confidence that is closer to the actual situation, and provides a judgment indicator with interpretability and consistency.
[0076] The defect detection method provided by the present invention comprises the following steps:
[0077] Step 1: The abnormal areas of the collected industrial images are labeled at the pixel level to obtain labels that may be inconsistent. The industrial images are paired with the corresponding labels, and the data set composed of industrial images is divided into training sets and test sets according to a certain ratio.
[0078] In this embodiment, industrial site images are collected and size normalized, abnormal areas are labeled at the pixel level to generate a data set, industrial images are paired with corresponding labels, and the data set is divided into a training set and a test set according to a certain ratio (usually 2 / 3 to 4 / 5).
[0079] Among them, an industrial image data set is obtained, the industrial images are paired with corresponding labels, and the data is divided into a training set and a test set according to a certain ratio, wherein the training set is used to train the constructed scoring Bayesian neural network to obtain an optimized parameterized model, and the test set is used to evaluate the performance of the trained parameterized model. In this embodiment, the ratio of samples in the training set to the test set is preferably 2 / 3 to 4 / 5.
[0080] Step 2: Based on the rough set theory, a label uncertainty model is established. The area determined to be abnormal in the image is divided into a certain area, whose boundary is the supremum; the area suspected to be abnormal is divided into a suspected area, whose boundary is the infimum, and the area between the supremum and the infimum is the uncertain area.
[0081] Assume a pair of non-empty sets Ω = (U, A), where U is the set of all pixels in the image, and A is the set of all features of the pixels (such as texture, grayscale, etc.). Any subset B of A determines an indistinguishability relation I(B). The image region determined by the subset B is denoted as U / B, and the pixel x belongs to U / B and is denoted as B(p). In the abnormal area In the definition, the lower approximation is B * (X), the upper approximation is B * (X), the expression is:
[0082]
[0083]
[0084] The uncertainty areas are:
[0085] BN B (X) = B * (X)-B * (X).
[0086] Step three, constructing a scoring Bayesian neural network, the scoring Bayesian neural network includes a Bayesian segmentation network and a scoring network, using a training set to train the Bayesian segmentation network and the scoring network to obtain a parameterized model of the Bayesian segmentation network and a parameterized model of the scoring network, and using a test set to evaluate the scoring network to obtain the optimal parameterized model of the scoring network.
[0087] Among them, the images in the training set are input into the Bayesian segmentation network for multiple solutions to obtain multiple abnormal segmentation maps, and the multiple abnormal segmentation maps obtained are compared with the labels respectively to obtain multiple segmentation errors; the images and labels in the training set are input into the scoring network together to obtain the quality evaluation score of the label. Then, the mean of the obtained segmentation error and the corresponding quality evaluation score are used as the segmentation loss for iterative training of the Bayesian segmentation network to obtain the parameterized model of the Bayesian segmentation network. The label of the quality evaluation score is calculated using the variance of the segmentation error, and the quality evaluation score is compared with the label of the quality evaluation score to obtain the scoring loss and used for iterative training of the scoring network, thereby obtaining the parameterized model of the scoring network. In addition, the samples in the test set are used to evaluate the scoring network, and the optimal parameterized model is selected in a certain number of training rounds.
[0088] The Bayesian segmentation network consists of an encoder, an intermediate layer, and a decoder connected end to end; wherein each downsampling during encoding includes two convolutional neural network modules and a maximum pooling layer connected in sequence, which is composed of several downsamplings, and the last two downsamplings of encoding include two spatially related Bayesian convolutional neural network modules and a maximum pooling layer connected in sequence; wherein the intermediate layer includes two spatially related Bayesian convolutional neural network modules connected in sequence; wherein each upsampling during decoding includes a linear interpolation layer and two convolutional neural network modules connected in sequence, and the last layer is a convolutional layer; convolutional neural network module, spatially related Bayesian convolutional neural network module, maximum pooling layer, convolutional layer, linear interpolation layer; wherein the convolutional neural network module includes a convolutional layer connected in sequence, a batch normalization layer and a ReLU activation layer; the spatially related Bayesian convolutional neural network module includes a convolutional layer, a spatial Dropout layer, and a batch normalization layer connected in sequence.
[0089] Among them, the scoring network consists of several downsamplings, each downsampling includes two convolutional neural network modules connected in sequence and a maximum pooling layer, and the last downsampling includes two convolutional neural network modules connected in sequence and a global maximum pooling layer.
[0090] The training of the Bayesian segmentation network and the scoring network mainly includes the following steps:
[0091] Step 1: training set samples {x1,...,x N} and labels {y1,...,y N} Input the Bayesian segmentation network and get the i-th th Multiple segmentation results of samples Compare the segmentation results and labels, obtain the cross entropy loss Bce Loss and the set similarity loss Dice Loss, and combine Bce Loss and Dice Loss to get the segmentation error Seg error.
[0092] Step 2: Transform the training set samples {x1,...,x N} and labels {y1,...,y N} Input the scoring network and get the corresponding quality evaluation score {s1,...,s N}.
[0093] Step 3: Mean of segmentation error i and the corresponding quality evaluation scores {s1,...,s N} multiplied as segmentation loss Loss seg , and use this to iteratively train the Bayesian segmentation network to obtain a parameterized model of the Bayesian segmentation network.
[0094] Step 4: The variance of the segmentation error Var i Make a label ls for the quality evaluation score i .
[0095] Step 5: Set the label quality evaluation scores {s1,...,s N} and the label ls of the quality evaluation score i Compare and get the score loss Loss score It is used for iterative training of the scoring network to obtain a parameterized model of the scoring network.
[0096] The cross entropy loss Bce Loss:
[0097]
[0098] V represents the segmented abnormal area, and the set similarity loss Dice Loss is:
[0099]
[0100] λ represents a trade-off hyperparameter used to control the relative importance of these two items, and λ>0. The segmentation error Seg error is:
[0101]
[0102] The mean of the segmentation error Seg error i and variance Var i They are:
[0103]
[0104]
[0105] The training set samples {x1,...,x N} and labels {y1,...,y N} Input the scoring network and get the corresponding quality evaluation score {s1,...,s N}, the segmentation loss Loss seg for:
[0106]
[0107] The labels for the quality assessment scores are:
[0108]
[0109] The scoring loss of the evaluation network is:
[0110]
[0111] Abnormal segmentation probability map p(x * )for:
[0112]
[0113] The scoring Bayesian neural network constructed by training the training set is used to obtain the parameter optimization model. The performance of the trained parameter optimization model is evaluated using the test set. The optimal parameterized model is selected based on the test results, and then the training set samples are input into the optimal parameterized model to obtain the final anomaly segmentation probability map.
[0114] Step 4: Input the sample to be tested into the Bayesian segmentation network, solve it multiple times to obtain multiple abnormal segmentation maps, input the multiple abnormal segmentation maps together with the corresponding images into the scoring network to obtain multiple quality evaluation scores, and multiply the abnormal segmentation map with the corresponding quality evaluation score to obtain the final abnormal segmentation probability map.
[0115] The specific steps include:
[0116] Step 1: Collect the image x to be detected * , input the optimal parameter model, and solve k through the Bayesian segmentation network thSecond, get the segmentation result
[0117] Step 2: Transform the image x * And the segmentation result Input the scoring network to get the corresponding score
[0118] Step 3: Multiply the abnormal segmentation map with the corresponding quality evaluation score and obtain the final abnormal segmentation probability map p(x * ).
[0119] Step 5: Determine the defect threshold and confidence threshold according to actual production requirements, obtain the confidence based on the defect threshold and the abnormal segmentation probability map, compare the obtained confidence with the confidence threshold, and determine whether there is a surface defect based on the comparison result.
[0120] Among them, according to the needs in actual production, a defect threshold is set, which represents the threshold for judging whether an abnormality can be a defect, and is usually set according to national standards or factory standards; a confidence calculation method is designed to obtain the confidence based on the defect threshold and the abnormal segmentation probability map in step S5; a confidence threshold is set according to the factory's quality requirements. If the confidence is greater than or equal to the confidence threshold, it is judged as NG, and if it is less than the confidence threshold, it is judged as OK. Specifically, the following steps are included:
[0121] Step 1: According to the actual production needs, the defect threshold T representing whether an abnormality can be judged as a defect is usually set according to national standards, industry standards or factory standards.
[0122] Step 2: Based on the defect threshold T and the abnormal segmentation probability map p(x * ) to obtain the confidence
[0123] Step 3: Set the confidence threshold according to the factory's quality requirements. If the confidence is greater than or equal to the confidence threshold, it is judged as NG; if it is less than the confidence threshold, it is judged as OK.
[0124] The confidence The calculation method is:
[0125] Determine c, and its range is [0,1]. When c - = 0, we get the lower bound, when c + =1, the supremum is obtained; GD is the geometric size of the abnormal area, such as length, diameter, area, etc., y is the value of each pixel in the image,
[0126]
[0127] Then the confidence level is:
[0128]
[0129] Among them, g -1 (T) is the inverse function of g(T).
[0130] In this embodiment, according to the actual production needs, the defect threshold T representing whether an abnormality can be judged as a defect is usually set according to the national standard, industry standard or factory standard; according to the defect threshold T and the abnormal segmentation probability map p(x * ) to obtain the confidence The confidence threshold is set according to the factory's quality requirements. If the confidence is greater than or equal to the confidence threshold, it is judged as NG; if it is less than the confidence threshold, it is judged as OK.
[0131] like Figure 4 As shown, the confidence The calculation method is:
[0132] Define c, and its range is [0,1], when c - = 0, we get the lower bound, when c + =1, the supremum is obtained; GD is the geometric size of the abnormal area, such as length, diameter, area, etc., and y is the value of each pixel in the image:
[0133]
[0134] Then the confidence level is:
[0135]
[0136] Among them, g -1 (T) is the inverse function of g(T).
[0137] The present invention is further described in detail below with reference to specific embodiments.
[0138] Example 1
[0139] A method for learning a defect detection model from inconsistent labels to implement surface defect detection in this embodiment includes the following steps:
[0140] (1) Generate a dataset;
[0141] In this example, a total of 900 steel images were collected to form the dataset NEU-seg, which contains three types of defects: inclusion, patches, and scratches. The image format is PNG. Some of the image training and test sets are as follows: Figure 5 As shown in Table 1, each image is normalized to the same pixel size of 256×256 (unit: pixel). The images are divided into training set and test set, as shown in Table 1.
[0142] Table 1 Dataset MCSD-cylinder
[0143] type Training set Test Set total Inclusion 210 90 300 Patches 210 90 300 Scratches 210 90 300
[0144] (2) Construct an automatic memory adversarial autoencoder model;
[0145] In this embodiment, a scoring Bayesian network model is constructed on the Pytorch1.4 deep learning framework.
[0146] (3) Dataset training and model optimization;
[0147] (3-1) Write a Python program to randomly sort the training samples and evenly distribute them. The batch size of each batch is 4 (unit: sheets);
[0148] (3-2) The training images are input into the model in batches. When the sum of the gradient descent values of all samples in a batch is calculated, the weights are updated once and all batches are updated. The trained model is evaluated using the test set to obtain an evaluation value (the AUC value is used in this example). If the evaluation value is greater than the existing maximum evaluation value, the existing parameterized model is stored and the next iteration is performed. If it is less than the maximum evaluation value, the next iteration is performed directly. The number of training sample iterations is 1000. After the iteration, the optimal parameterized network model is obtained, named BNN-SDD-MCSD-seg1000model.
[0149] (3-4) The trained model is tested by inputting the test set, and various indicators are obtained. The results are listed in Table 2. The BNN-SDD-MCSD-seg1000model is tested on the model. The total accuracy of the test set is 0.865, and the recall rate of NG samples is 1.000, which achieves very accurate anomaly recognition.
[0150] Table 2 Overall evaluation indicators of BNN-SDD model
[0151] network Intersection and Union F1 score FPS SDMA 0.7771 1.9329 67.11
[0152] (4) Online detection;
[0153] Collect the images to be detected. In this example, 8 images are implemented and the size is normalized to 256×256. The image matrix is directly input into the BNN-SDD-MCSD-seg1000model to obtain the segmentation probability map. After that, the confidence can be obtained according to the threshold, but since the NEU-seg dataset comes from the Internet, this step is not shown.
[0154] Those skilled in the art will readily appreciate that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A method for detecting defects from inconsistent labels, It is characterized in that The method comprises the following steps: (1) Abnormal areas of industrial images are labeled at the pixel level to obtain labels that may be inconsistent. The resulting dataset is divided into a training set and a test set. (2) Based on the rough set theory, a label uncertainty model is established. The area in the image that is determined to be abnormal is divided into a certain area, whose boundary is the supremum; the area suspected to be abnormal is divided into a suspected area, whose boundary is the infimum, and the area between the supremum and the infimum is the uncertain area; (3) constructing a scoring Bayesian neural network, wherein the scoring Bayesian neural network includes a Bayesian segmentation network and a scoring network, training the scoring Bayesian neural network using a training set to obtain a parameterized model of the scoring Bayesian neural network, and evaluating the scoring Bayesian neural network using a test set to obtain an optimal parameterized model of the scoring Bayesian neural network; (4) Inputting the sample to be detected into the Bayesian segmentation network, solving multiple times to obtain multiple abnormal segmentation maps, inputting the multiple abnormal segmentation maps together with the corresponding images into the scoring network to obtain multiple quality evaluation scores, and multiplying the abnormal segmentation map with the corresponding quality evaluation score to obtain the final abnormal segmentation probability map; (5) Determine the defect threshold and confidence threshold according to actual production needs, obtain the confidence based on the defect threshold and the abnormal segmentation probability map, compare the obtained confidence with the confidence threshold, and determine whether there is a surface defect based on the comparison result.
2. The method for detecting defects from inconsistent labels as claimed in claim 1, Features: For a pair of non-empty sets Ω = (U, A), where U is the set of all pixels in the image, and A is the set of all features of the pixels; any subset B of A determines an indistinguishability relation I(B), the image region determined by the subset B is denoted as U / B, and the pixel x belongs to U / B and is denoted as B(p). In the abnormal region In the definition, the lower approximation is B * (X), the upper approximation is B * (X), the corresponding expressions are: The uncertainty areas are: BN B (X)=B * (X)-B * (X)。 3. The method for detecting defects from inconsistent labels as claimed in claim 1, Features: The images in the training set are input into the Bayesian segmentation network for multiple solutions to obtain multiple abnormal segmentation maps, and the multiple abnormal segmentation maps are compared with the labels to obtain multiple segmentation errors; the images and labels in the training set are input into the scoring network together to obtain the quality evaluation score of the label, and then the mean of the obtained segmentation errors and the corresponding quality evaluation score are used as the segmentation loss for iterative training of the Bayesian segmentation network, and the variance of the segmentation error is used as the scoring loss for iterative training of the scoring network to obtain a parameterized model of the scoring Bayesian neural network.
4. The method for detecting defects from inconsistent labels as claimed in claim 1, Features: The Bayesian segmentation network consists of an encoder, an intermediate layer, and a decoder connected end to end; the encoder contains several downsampling and several layers of spatially related Bayesian neural network modules; the intermediate layer consists of several layers of spatially related Bayesian neural network modules; the decoder contains several layers of upsampling layers; the spatially related Bayesian convolutional neural network module contains a convolutional layer, a spatial Dropout layer, and a batch normalization layer connected in sequence; the scoring network consists of several downsampling, and the last layer is a global maximum pooling layer.
5. A method for detecting defects from inconsistent labels as claimed in any one of claims 1 to 4, Features: The training of the scoring Bayesian neural network consists of the following steps: (1) Training set samples {x 1 ,...,x N } and label {y 1 ,...,y N } Input the Bayesian segmentation network and get the i-th th Multiple segmentation results of samples Compare the segmentation results and labels to obtain the cross entropy loss Bce Loss and the set similarity loss Dice Loss. Combine Bce Loss and Dice Loss to get the segmentation error Seg error. (2) The training set samples {x 1 ,...,x N } and label {y 1 ,...,y N } Input the scoring network to get the corresponding quality evaluation score {s 1 ,...,s N }; (3) Mean of segmentation error i The corresponding quality evaluation score {s 1 ,...,s N } multiplied as segmentation loss Loss seg , and use this to iteratively train the Bayesian segmentation network to obtain a parameterized model of the Bayesian segmentation network; (4) The variance of the segmentation error Var i Make a label ls for the quality evaluation score i ; (5) The label quality evaluation score {s 1 ,...,s N } and the label ls of the quality evaluation score i Compare and get the score loss Loss score It is used for iterative training of the scoring network to obtain a parameterized model of the scoring network.
6. The method of detecting defects from inconsistent labels as claimed in claim 5, Features The cross entropy loss Bce Loss is: V represents the segmented abnormal area, and the set similarity loss Dice Loss is: λ represents a trade-off hyperparameter used to control the relative importance of these two items, and λ>0, the segmentation error Segerror is: The mean of the segmentation error Seg error i and variance Var i They are: The training set samples {x 1 ,...,x N } and label {y 1 ,...,y N } Input the scoring network to get the corresponding quality evaluation score {s 1 ,...,s N }, the segmentation loss Loss seg for: The labels of the quality assessment scores are: The scoring loss of the evaluation network is:
7. The method for detecting defects from inconsistent labels according to claim 1, Features: The acquisition of the abnormal probability segmentation map comprises the following steps: Step 1: Collect the image x to be detected * , input into the optimal parameterized model, and solve k through the Bayesian segmentation network th Second, get the segmentation result Step 2: Transform the image x * And the segmentation result Input the scoring network to get the corresponding score Step 3: Multiply the abnormal segmentation map with the corresponding quality evaluation score and obtain the final abnormal segmentation probability map p(x * ).
8. The method for detecting defects from inconsistent labels according to claim 1, Features: The abnormal segmentation probability map p(x * )for:
9. The method for detecting defects from inconsistent labels according to claim 1, Features: Determining whether an anomaly is a defect includes the following steps: The first step is to set a defect threshold T representing whether an abnormality can be considered a defect, usually based on national standards, industry standards or factory standards, according to actual production needs; The second step is to use the defect threshold T and the abnormal segmentation probability map p(x * ) to obtain the confidence The third step is to set a confidence threshold based on quality requirements. If the confidence is greater than or equal to the confidence threshold, it is judged as NG; if it is less than the confidence threshold, it is judged as OK.
10. The method of detecting defects from inconsistent labels as claimed in claim 9, Features: The confidence The calculation method is: Determine c, and its range is [0,1]. When c - = 0, we get the lower bound, when c + =1, the supremum is obtained; GD is the geometric size of the abnormal area, and y is the value of each pixel in the image; Then the confidence level is: Among them, g -1 (T) is the inverse function of g(T).
