Defect detection method and system based on two-stage generative adversarial network

Through the two-stage generation adversarial network to generate defect samples with labeled information, the problem of defect detection models depend on labeled sample data in the prior art is solved, and higher detection accuracy and generalization capabilities are achieved.

CN119693295AActive Publication Date: 2025-03-25JIEYANG GUIQIAN INFORMATION TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411507405.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-03-25
Estimated Expiration
2044-10-28

AI Technical Summary

Technical Problem

The prior art requires a large amount of sample data to be marked in defect detection, resulting in a weaker model's ability to detect defects.

Method used

The defect detection method based on a two-stage generation adversarial network is adopted, and the defect generation network driven by the BayesGAN defect mask is used to generate defect samples with labeled information, and the defect detection network for training is combined with the defect detection network for segmentation decisions.

Benefits of technology

Without the need for a large amount of manual annotation of data, the generated defect detection model significantly improves detection accuracy and generalization ability, and can more accurately identify multiple defect types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119693295A_ABST
    Figure CN119693295A_ABST
Patent Text Reader

Abstract

The invention discloses a defect detection method and system based on a two-stage generative adversarial network. Comprising the following steps: acquiring a defect sample data set and a non-defective sample data set, and marking the defect sample to become a defect mask sample; training a BayesGAN defect mask generation network by using the defect mask sample; utilizing a non-defect texture extraction network to obtain a feature map of a good product sample and calculating a style condition Gramer matrix of the good product sample; training a defect generation network driven by a mask by utilizing the style condition Gramer matrix of the good product sample, the defect sample and the defect mask sample; training the defect detection network based on the segmentation decision by using the output of the generators of the two trained generative networks; and inputting a to-be-detected sample into the defect detection network, and outputting a defect detection result. According to the method, the defect sample is generated by the double-stage generative adversarial network, a large amount of training data containing labels is provided for the defect detection model, and manual later-stage labeling is not needed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of deep learning and computer vision technology, and more specifically, relates to a defect detection method and system based on a two-stage generative adversarial network. Background Art

[0002] In industry, transportation, national defense and daily life, various types of equipment are indispensable and important components, and their downstream industries cover almost all basic areas of the national economy. The core components of these devices are facing growing demand while accompanying the continuous development of related industries. These core components play key functions in the production process and are widely used in defense, military, aviation and civil facilities. However, the production process is inevitably disturbed by uncontrollable factors from the outside world, resulting in various defects in the components. Take scratch defects as an example. They may appear on the side of the component. Due to slight scratches on the machine tool during the manufacturing process, they usually appear in strips and dark colors. Such defects will destroy the insulation between materials, cause short circuits, and then damage the product. Therefore, for the core components of various types of equipment, it is particularly important to accurately identify abnormal samples to avoid possible serious consequences. Although deep learning has made significant progress in the field of defect detection, it still faces many challenges, such as lack of labeled sample data, limited feature learning ability, insufficient detection accuracy, and weak model generalization ability.

[0003] The invention patent with the prior art publication number CN112365478A proposes a motor commutator surface defect detection model based on semantic segmentation, including the following steps: divide the data set into three parts, select two of them as training sets and the other as test sets, repeat three times, and perform triple cross validation; input the training data into the segmentation network, train the segmentation network using pixel segmentation labels, and output the semantic segmentation results; input the results of the segmentation network into the classification network, first freeze the weight parameters of the trained segmentation network, and then train the classification network according to the labels, the defective sample label is 1, and the non-defective sample label is 0; input the test data into the trained segmentation network and classification network, and output a probability value between 0 and 1. The greater the probability, the higher the possibility of defects. 0.9 is selected as the threshold for judging positive and negative samples. Samples greater than or equal to 0.9 are defective samples (positive samples), and samples less than 0.9 are non-defective samples (negative samples). This method requires a large amount of labeled sample data when training the defect detection model, but the reality often lacks labeled sample data, which ultimately leads to the model's weak ability to detect defects. Summary of the invention

[0004] In order to overcome the problem in the prior art that a large amount of labeled sample data is needed to improve the model's defect detection capability, the present invention provides a defect detection method and system based on a two-stage generative adversarial network.

[0005] The primary purpose of the present invention is to solve the above technical problems. The technical solution of the present invention is as follows:

[0006] A first aspect of the present invention provides a defect detection method based on a two-stage generative adversarial network, comprising the following steps:

[0007] Obtain a data set, the data set includes defective samples and good product samples, mark the defective samples and add defect masks to them to make them defect mask samples;

[0008] Training a BayesGAN defect mask generation network using defect mask samples, wherein the network includes a first generator and a first discriminator that are trained in collaboration;

[0009] Use the preset non-defective texture extraction network to obtain the feature map of the good sample and calculate its style conditional Gram matrix;

[0010] Using the style conditional Gram matrix of good product samples, defect samples and defect mask samples to train a mask-driven defect generation network, the network comprising a second generator and a second discriminator that are trained in a collaborative manner;

[0011] Generate defect samples with labeled information using the trained first generator and the second generator, add the defects to the data set, and use the added data set to train a defect detection network based on segmentation decision;

[0012] The sample to be detected is input into the defect detection network, and the defect detection result is output.

[0013] Furthermore, the steps of training the BayesGAN defect mask generation network are:

[0014] The weight parameters of the first generator are fixed, and noise obeying Gaussian distribution is randomly sampled. The noise is converted into a geometric mask map through the first generator G, and the geometric mask map G(z) and the defect mask sample are input into the first discriminator. The first discriminator is trained and its weight parameters are updated using the loss function. The loss function D loss Defined as:

[0015] D loss = -log[D(x)]+log[D(G(z))]

[0016] Where x is the defect mask sample image, z is the randomly sampled noise that follows the Gaussian distribution, D and G represent the first discriminator and the first generator respectively;

[0017] The weight parameters of the first discriminator are fixed, and noise obeying Gaussian distribution is randomly sampled. The noise is converted into a geometric mask map through the first generator G, and the generated geometric mask map G(z) is input into the first discriminator. The first generator is trained and its weight parameters are updated using the loss function. The loss function G loss Defined as:

[0018] G loss = -log[D(G(z))]

[0019] Where z is a randomly sampled noise that follows a Gaussian distribution, D and G represent the first discriminator and the first generator, respectively;

[0020] Repeat the above steps until the BayesGAN defect mask generation network model converges.

[0021] Furthermore, the steps of obtaining the feature graph of the good sample and calculating its style conditional Gram matrix are:

[0022] Input the good sample image into the preset non-defective texture extraction network and output the feature map;

[0023] The style conditional Gram matrix is ​​calculated using the output feature map. The formula is as follows:

[0024]

[0025] Among them, x is the feature map, That is, the matrix [C, WH]. W, H, C are the width, height, and number of channels of the feature map respectively.

[0026] Furthermore, the preset non-defective texture extraction network includes the first five blocks of the VGG-16 network.

[0027] Furthermore, the steps of training the mask-driven defect generation network are:

[0028] Fix the weight parameters of the second generator and use the defect mask sample image x as the second generator G t The style conditional Gram matrix GM(y) of the good sample is used as the second generator G t Conditional input to generate defect sample G t (x, GM(y)), and the style condition Gram matrix GM(y) of the defective sample image l and the good sample are input into the second discriminator, the loss function is calculated and the weight parameters of the second discriminator are updated. The loss function Defined as:

[0029]

[0030] Among them, Dt , G t represent the second discriminator and the second generator respectively;

[0031] Fix the weight parameters of the second discriminator and use the defect mask sample image x as the second generator G t The style conditional Gram matrix GM(y) of the good sample is used as the second generator G t Conditional input to generate defect sample G t The style conditional Gram matrix GM(y) of (x, GM(y)) and the good sample is input into the second discriminator, the loss function is calculated and the weight parameters of the second generator are updated. The loss function Defined as:

[0032]

[0033] The above steps are repeated until the mask-driven defect generation network model converges.

[0034] Furthermore, the trained first generator and the trained second generator can generate any number of defect samples with labeled information.

[0035] Furthermore, the steps of training the defect detection network based on segmentation decision are:

[0036] Randomly sample a fixed batch of noise that follows a Gaussian distribution, generate a defect geometry mask through the trained first generator, and then generate a defect image through the trained second generator, input the generated defect geometry mask, the generated defect image and the original image into a preset shared network, and output a high-level feature map;

[0037] The extracted feature map is input into the preset segmentation network to output the defect segmentation heat map, and the high-level feature map is combined with the preset classification network to output the feature map;

[0038] The defect segmentation heat map of the segmentation network is globally averaged and pooled, and then fused with the output feature map of the classification network. After passing through the fully connected layer and the preset function output, the probability of defects in the entire image is represented. The loss function is calculated and the network parameters are updated. The loss function L is defined as:

[0039]

[0040] Where C is the number of categories, x is the test sample, p(x i ) is the probability of detecting a sample as class i, q(x i ) is the probability that the test sample is predicted to be class i.

[0041] Furthermore, the preset classification network is a classification network embedded with a residual attention module; the preset shared network includes three convolutional layers and three pooling layers, each convolutional layer includes a BN layer and a RELU layer; the preset segmentation network includes four convolutional layers.

[0042] Furthermore, the preset function whose output represents the probability of defects existing in the entire image is a sigmoid function.

[0043] A second aspect of the present invention provides a defect detection system based on a two-stage generative adversarial network, the system comprising: a memory, a processor, the memory comprising a defect detection method program based on a two-stage generative adversarial network, the defect detection method program based on a two-stage generative adversarial network being executed by the processor to implement the following steps:

[0044] Obtain a data set, the data set includes defective samples and good product samples, mark the defective samples and add defect masks to them to make them defect mask samples;

[0045] Training a BayesGAN defect mask generation network using defect mask samples, wherein the network includes a first generator and a first discriminator that are trained in collaboration;

[0046] Use the preset non-defective texture extraction network to obtain the feature map of the good sample and calculate its style conditional Gram matrix;

[0047] Using the style conditional Gram matrix of good product samples, defect samples and defect mask samples to train a mask-driven defect generation network, the network comprising a second generator and a second discriminator that are trained in a collaborative manner;

[0048] Generate defect samples with labeled information using the trained first generator and the second generator, add the defects to the data set, and use the added data set to train a defect detection network based on segmentation decision;

[0049] The sample to be detected is input into the defect detection network, and the defect detection result is output.

[0050] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:

[0051] The present invention obtains a defect detection model by using a defect detection method based on a two-stage generative adversarial network, and proposes a two-stage generative adversarial network to generate defect samples; a large amount of labeled training data is provided for the defect detection model, and no manual post-labeling is required; the segmentation network and the attention mechanism are integrated into the defect detection classification network, thereby improving the detection capability of the defect detection network. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to make the purpose and technical solution of the present invention clearer, the present invention provides the following drawings and descriptions:

[0053] Figure 1 A flow chart of a method provided by an embodiment of the present invention;

[0054] Figure 2 A defect mask sample diagram provided by an embodiment of the present invention;

[0055] Figure 3 A geometric mask map provided by an embodiment of the present invention;

[0056] Figure 4 A first generative adversarial network data framework diagram of a defect detection method based on a two-stage generative adversarial network provided by an embodiment of the present invention;

[0057] Figure 5 A process diagram for generating defect samples provided by an embodiment of the present invention;

[0058] Figure 6 A second generative adversarial network data framework diagram of a defect detection method based on a two-stage generative adversarial network provided by an embodiment of the present invention;

[0059] Figure 7 A defect detection framework diagram based on segmentation decision of a defect detection method based on a two-stage generative adversarial network provided in an embodiment of the present invention; DETAILED DESCRIPTION

[0060] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0061] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.

[0062] The present invention provides a defect detection method based on a two-stage generative adversarial network, such as Figure 1 The figure shows a flow chart of a defect detection method based on a two-stage generative adversarial network. The specific steps are as follows:

[0063] S1: Obtain a data set, which includes defective samples and good product samples. In a specific embodiment, it is necessary to obtain 15 sample images with different defects and 15 good product sample images on the production line, annotate the defective samples and add defect masks to them to make them defect mask samples, such as Figure 2 As shown;

[0064] S2: training a BayesGAN defect mask generation network using the defect mask sample, wherein the network comprises a first generator and a first discriminator that are trained in collaboration;

[0065] The specific process is:

[0066] The weight parameters of the first generator are fixed, and noise that obeys the Gaussian distribution z~p(z) is randomly sampled. In a specific embodiment, a 100-dimensional vector that obeys the normal distribution is randomly sampled, and the noise is converted into a 800x200 geometric mask image G(z) through the first generator G, as shown in FIG. Figure 3 As shown, the geometric mask image G(z) and the defect mask sample x are input into the first discriminator, as Figure 4 As shown, the first discriminator is trained and its weight parameters are updated using the loss function. The loss function D loss Defined as:

[0067] D loss = -log[D(x)]+log[D(G(z))]

[0068] Where z is randomly sampled Gaussian noise, D and G represent the first discriminator and the first generator respectively;

[0069] The weight parameters of the first discriminator are fixed, and noise with Gaussian distribution z~p(z) is randomly sampled. The noise is converted into a geometric mask map through the first generator G, and the generated geometric mask map G(z) is input into the first discriminator. The first generator is trained and its weight parameters are updated using the loss function. The loss function G loss Defined as:

[0070] G loss = -log[D(G(z))]

[0071] Where z is randomly sampled Gaussian noise, D and G represent the first discriminator and the first generator respectively;

[0072] Repeat the above steps until the BayesGAN defect mask generation network model converges.

[0073] S3: Use the preset non-defective texture extraction network to obtain the feature map of the good sample and calculate its style conditional Gram matrix;

[0074] The specific process is:

[0075] The good sample image is scaled to 256x256 and then input into the preset non-defect texture extraction network, which outputs a 16x16 feature map.

[0076] The style conditional Gram matrix is ​​calculated using the output feature map. The formula is as follows:

[0077]

[0078] Among them, x is the feature map, That is, the matrix [C, WH]. W, H, C are the width, height, and number of channels of the feature map respectively.

[0079] It should be noted that the preset non-defective texture extraction network includes the first five blocks of the VGG-16 network.

[0080] S4: training a mask-driven defect generation network using the style conditional Gram matrix of the good sample, the defect sample and the defect mask sample, wherein the network includes a second generator and a second discriminator that are trained in a collaborative manner;

[0081] The specific process is:

[0082] Fix the weight parameters of the second generator and use the defect mask sample image x as the second generator G t The style conditional Gram matrix GM(y) of the good sample is used as the second generator G t Conditional input to generate defect sample G t (x,GM(y)), such as Figure 5 As shown. The defect sample G will be generated t (x, GM(y)), and the style conditional Gram matrix GM(y) of the defective sample image l and the good sample are input into the second discriminator, such as Figure 6 As shown, the loss function is calculated and the weight parameters of the second discriminator are updated. The loss function Defined as:

[0083]

[0084] Among them, D t , G t represent the second discriminator and the second generator respectively;

[0085] Fix the weight parameters of the second discriminator and use the defect mask sample image x as the second generator G t The style conditional Gram matrix GM(y) of the good sample is used as the second generator G t Conditional input to generate defect sample G t The style conditional Gram matrix GM(y) of (x, GM(y)) and the good sample is input into the second discriminator, the loss function is calculated and the weight parameters of the second generator are updated. The loss function Defined as:

[0086]

[0087] The above steps are repeated until the mask-driven defect generation network model converges.

[0088] S5: using the trained first generator and the second generator to generate defect samples with labeled information, adding the defects to the data set, and using the supplemented data set to train a defect detection network based on segmentation decision;

[0089] It should be noted that the trained first generator and the second generator can generate any number of defect samples with labeled information.

[0090] The specific process is:

[0091] A fixed batch of noises that obey a Gaussian distribution are randomly sampled, a defect geometry mask is generated by a trained first generator, and a defect image is generated by a trained second generator. The generated defect geometry mask, the generated defect image, and the original image are input into a preset shared network. In a specific embodiment, the shared network is composed of 3 convolutional layers and pooling layers, each convolutional layer includes a BN layer and a RELU layer, and outputs a 128-channel high-level feature map;

[0092] The extracted feature map is input into a preset segmentation network. In a specific embodiment, the segmentation network consists of 4 convolutional layers, the convolution kernel size of the first two layers is 3x3, the convolution kernel size of the third layer is 5x5, and the convolution kernel size of the last layer is 1x1. Finally, the output feature map is predicted at the pixel level through the sigmoid function, and a 1-channel defect segmentation heat map is output. The high-level feature map is combined with the input of the classification network embedded with the residual attention module RSAM. In a specific embodiment, after the attention layer and 3 convolutional layers, a 256-channel feature map is output, such as Figure 7 As shown;

[0093] The defect segmentation heat map of the segmentation network is globally averaged and pooled, and then fused with the output feature map of the classification network. After the fully connected layer and the sigmoid function output, the probability of defects in the entire image is represented. The loss function is calculated and the network parameters are updated. The loss function L is defined as:

[0094]

[0095] Where C is the number of categories, x is the test sample, p(x i ) is the probability of detecting a sample as class i, q(x i ) is the probability that the test sample is predicted to be class i.

[0096] S6: Input the sample to be detected into the defect detection network and output the defect detection result.

[0097] The following experimental model code is implemented based on Pytorch and trained on a graphics card with two NVIDIA GeForce RTX2070Supers. The data batch size is 32, the stochastic gradient descent algorithm is used, and the learning rate is 0.005. The experimental data is shown in Table 1.

[0098] Table 1

[0099]

[0100]

[0101] Among them, U-Net and FCN segmentation decision methods are existing models. As can be seen from Table 1, the scheme of the present invention shows higher detection accuracy than the existing methods when detecting various defect types (such as scratches, bruises, and stains). Taking scratch detection as an example, the average precision (AP) of the present invention reaches 94.14%, which is significantly better than 92.56% of U-Net and 91.25% of FCN. Not only does the detection accuracy improve, the present invention also has excellent performance in reducing false positives (FP) and false negatives (FN). In the scratch detection of 45 samples, the FP+FN of the present invention is 9, which is lower than 13 of U-Net and 14 of FCN. In stain detection, the FP+FN of the present invention is only 5, which is also better than the performance of U-Net and FCN. In addition, the present invention performs stably under different sample sizes. Even when the training samples are reduced to 30, the AP of scratch detection still reaches 93.19%, and the AP of bruise detection is 95.83%, showing its superior performance when the sample size changes.

[0102] A second aspect of the present invention provides a defect detection system based on a two-stage generative adversarial network, the system comprising: a memory, a processor, the memory comprising a defect detection method program based on a two-stage generative adversarial network, the defect detection method program based on a two-stage generative adversarial network being executed by the processor to implement the following steps:

[0103] Obtain a data set, the data set includes defective samples and good product samples, mark the defective samples and add defect masks to them to make them defect mask samples;

[0104] Training a BayesGAN defect mask generation network using defect mask samples, wherein the network includes a first generator and a first discriminator that are trained in collaboration;

[0105] Use the preset non-defective texture extraction network to obtain the feature map of the good sample and calculate its style conditional Gram matrix;

[0106] Using the style conditional Gram matrix of good product samples, defect samples and defect mask samples to train a mask-driven defect generation network, the network comprising a second generator and a second discriminator that are trained in a collaborative manner;

[0107] Generate defect samples with labeled information using the trained first generator and the second generator, add the defects to the data set, and use the added data set to train a defect detection network based on segmentation decision;

[0108] The sample to be detected is input into the defect detection network, and the defect detection result is output.

[0109] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.

Claims

1. A defect detection method based on a two-stage generative adversarial network, characterized in that: The steps include: Obtain a data set, the data set includes defective samples and good product samples, mark the defective samples and add defect masks to them to make them defect mask samples; Training a BayesGAN defect mask generation network using defect mask samples, wherein the network includes a first generator and a first discriminator that are trained in collaboration; Use the preset non-defective texture extraction network to obtain the feature map of the good sample and calculate its style conditional Gram matrix; Using the style conditional Gram matrix of good product samples, defect samples and defect mask samples to train a mask-driven defect generation network, the network comprising a second generator and a second discriminator that are trained in a collaborative manner; Generate defect samples with labeled information using the trained first generator and the second generator, add the defects to the data set, and use the added data set to train a defect detection network based on segmentation decision; The sample to be detected is input into the defect detection network, and the defect detection result is output.

2. A defect detection method based on a two-stage generative adversarial network according to claim 1, characterized in that: The steps of training the BayesGAN defect mask generation network are: The weight parameters of the first generator are fixed, and noise obeying Gaussian distribution is randomly sampled. The noise is converted into a geometric mask map through the first generator G, and the geometric mask map G(z) and the defect mask sample x are input into the first discriminator. The first discriminator is trained and its weight parameters are updated using the loss function. The loss function D loss Defined as: D loss =-log[D(x)]+log[D(G(z))] Where x is the defect mask sample image, z is the randomly sampled noise that follows the Gaussian distribution, D and G represent the first discriminator and the first generator respectively; The weight parameters of the first discriminator are fixed, and noise obeying Gaussian distribution is randomly sampled. The noise is converted into a geometric mask map through the first generator G, and the generated geometric mask map G(z) is input into the first discriminator. The first generator is trained and its weight parameters are updated using the loss function. The loss function G loss Defined as: G loss =-log[D(G(z))] Where z is a randomly sampled noise that follows a Gaussian distribution, D and G represent the first discriminator and the first generator, respectively; Repeat the above steps until the BayesGAN defect mask generation network model converges.

3. The defect detection method based on a two-stage generative adversarial network according to claim 1 is characterized in that: The steps of obtaining the feature graph of the good sample and calculating its style conditional Gram matrix are: Input the good sample image into the preset non-defective texture extraction network and output the feature map; The style conditional Gram matrix is ​​calculated using the output feature map. The formula is as follows: Among them, x is the feature map, That is, the matrix [C, WH]. W, H, C are the width, height, and number of channels of the feature map respectively.

4. A defect detection method based on a two-stage generative adversarial network according to claim 1 or 3, characterized in that: The preset non-defective texture extraction network includes the first five blocks of the VGG-16 network.

5. The defect detection method based on a two-stage generative adversarial network according to claim 1 is characterized in that: The steps of training the mask-driven defect generation network are: Fix the weight parameters of the second generator and use the defect mask sample image x as the second generator G t The style conditional Gram matrix GM(y) of the good sample is used as the second generator G t Conditional input to generate defect sample G t (x, GM(y)), and the style condition Gram matrix GM(y) of the defective sample image l and the good sample are input into the second discriminator, the loss function is calculated and the weight parameters of the second discriminator are updated. The loss function Defined as: Among them, D t , G t represent the second discriminator and the second generator respectively; Fix the weight parameters of the second discriminator and use the defect mask sample image x as the second generator G t The style conditional Gram matrix GM(y) of the good sample is used as the second generator G t Conditional input to generate defect sample G t The style conditional Gram matrix GM(y) of (x, GM(y)) and the good sample is input into the second discriminator, the loss function is calculated and the weight parameters of the second generator are updated. The loss function Defined as: The above steps are repeated until the mask-driven defect generation network model converges.

6. The defect detection method based on a two-stage generative adversarial network according to claim 1 is characterized in that: The trained first generator and the second generator can generate any number of defect samples with labeled information.

7. The defect detection method based on a two-stage generative adversarial network according to claim 1 is characterized in that: The steps of training the segmentation decision-based defect detection network are: Randomly sample a fixed batch of noise that follows a Gaussian distribution, generate a defect geometry mask through the trained first generator, and then generate a defect image through the trained second generator, input the generated defect geometry mask, the generated defect image and the original image into a preset shared network, and output a high-level feature map; The extracted feature map is input into the preset segmentation network to output the defect segmentation heat map, and the high-level feature map is combined with the preset classification network to output the feature map; The defect segmentation heat map of the segmentation network is globally averaged and pooled, and then fused with the output feature map of the classification network. After passing through the fully connected layer and the preset function output, the probability of defects in the entire image is represented. The loss function is calculated and the network parameters are updated. The loss function L is defined as: Where C is the number of categories, x is the test sample, p(x i ) is the probability of detecting a sample as class i, q(x i ) is the probability that the test sample is predicted to be class i.

8. The defect detection method based on a two-stage generative adversarial network according to claim 7 is characterized in that: The preset classification network is a classification network embedded with a residual attention module; the preset shared network includes three convolutional layers and three pooling layers, each convolutional layer includes a BN layer and a RELU layer; the preset segmentation network includes four convolutional layers.

9. The defect detection method based on a two-stage generative adversarial network according to claim 7 is characterized in that: The preset function whose output represents the probability of defects existing in the entire image is a sigmoid function.

10. A defect detection system based on a two-stage generative adversarial network, characterized in that: The system includes: a memory and a processor, wherein the memory includes a defect detection method program based on a two-stage generative adversarial network, and when the defect detection method program based on a two-stage generative adversarial network is executed by the processor, the steps of a defect detection method based on a two-stage generative adversarial network as described in any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Motor commutator surface defect detection model based on semantic segmentation

    CN112365478A

  • Defect image generation method based on generative adversarial network

    CN114022586A

  • Systems and methods for sample generation for identifying manufacturing defects

    US20220374720A1