A defect detection network model training method and system and a defect detection method
By combining a differential encoder, generator, and discriminator with multi-scale feature fusion and feature extraction, the problem of low detection accuracy in defect detection is solved, and the accurate location of defects and the improvement of detection effect are achieved.
Patent Information
- Application Number
- CN202310299739.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-20
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2043-03-20
AI Technical Summary
Existing technologies suffer from poor defect detection performance and low detection accuracy, especially in unsupervised learning where the model's generalization ability is too strong, making it unable to accurately select defective images.
A combination of differential encoder and generator is used. The differential encoder encodes defect-free images, the generator reconstructs the differentially encoded images, and the discriminator determines whether the reconstructed images are defect-free. The model is trained by combining a multi-scale feature fusion module and a feature extraction module and optimizing the model through a loss function.
It improves the accuracy and efficiency of defect detection, can stably train network models, suppress generalization ability, and achieve precise defect localization.
Smart Images

Figure CN116309496B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of defect detection, in particular to a defect detection network model training method and system and a defect detection method. BACKGROUND
[0002] Defect detection is a very important part of industrial production, and defect detection can greatly improve the efficiency of industrial production. With the wide application of deep learning technology in the field of industrial defect detection, supervised algorithms require a large number of defect pictures during deep learning training, which is difficult to obtain easily in actual industrial production process, and the cost of manual annotation is high, resulting in poor defect detection effect.
[0003] Unsupervised learning can only collect defect-free pictures and train based on defect-free pictures that can be obtained in large quantities. For example, a variational autoencoder or a generative adversarial network is used to reconstruct the picture. Since only defect-free pictures are used for training, when the model receives a defect picture, it cannot reconstruct the defect area to select the defect picture. The variational autoencoder is more likely to generate blurred pictures, and the generative adversarial network is unstable and prone to mode collapse, making it difficult to train. At the same time, due to the strong generalization ability of the model, even if only defect-free pictures are used for training, the model can usually reconstruct defects, and cannot accurately select defect pictures, thereby affecting the detection accuracy.
[0004] CN114332008A disclosed a multi-level feature reconstruction-based unsupervised defect detection and positioning method on April 12, 2022, which provided a training reconstruction network and a detection method. The model parameters are optimized using a loss function and an SGD optimizer. The optimized model is not accurate enough, resulting in inaccurate final defect detection. SUMMARY
[0005] To solve the above problems, the present application provides a defect detection network model training method, system and defect detection method, which can improve the defect detection effect and accurately locate the defects.
[0006] A defect detection network model training method, comprising the steps of:
[0007] S1, collecting a defect-free picture sample set;
[0008] S2, encoding the defect-free picture through a difference encoder to obtain a difference encoded picture;
[0009] S3, reconstructing the difference encoded picture through a generator to obtain a reconstructed picture;
[0010] S4, determining whether the reconstructed picture is a defect-free picture through a discriminator;
[0011] S5, repeating the iteration of steps S2-S4 and calculating the corresponding loss function to train the differential encoder, the generator and the discriminator until the discrimination result of the discriminator is the non-defect picture in a preset number of times, and then obtaining a defect detection network model including the trained differential encoder and the generator.
[0012] As preferred, in step S2, the step of:
[0013] S2.1, performing convolution processing on the non-defect picture by a down-sampling module to obtain a first feature map;
[0014] S2.2, performing convolution processing on the first feature map by a full connection module to obtain a standard deviation of a normal distribution and a mean value of the normal distribution;
[0015] S2.3, calculating the differential encoded picture based on the standard deviation of the normal distribution and the mean value of the normal distribution.
[0016] As preferred, between step S2 and step S3, the step of: inputting the differential encoded picture into a multi-scale feature fusion module to perform multi-scale fusion on the features of different dimensions of the differential encoded picture to obtain a second feature map of feature fusion, and inputting the second feature map of feature fusion into a feature extraction module after splicing to obtain an optimized differential encoded picture.
[0017] As preferred, in step S3, the step of:
[0018] S3.1, processing the differential encoded picture and the optimized differential encoded picture by a full connection module to obtain a third feature map;
[0019] S3.2, reconstructing the third feature map by an up-sampling module to obtain a differential encoded reconstructed picture and an optimized differential encoded reconstructed picture.
[0020] As preferred, in step S4, the step of:
[0021] S4.1, performing convolution processing on the differential encoded reconstructed picture, the optimized differential encoded reconstructed picture and the non-defect picture by a down-sampling module to obtain a differential encoded intermediate feature, an optimized differential encoded intermediate feature and an intermediate feature of the non-defect picture;
[0022] S4.2, discriminating the optimized differential encoded intermediate feature and the intermediate feature of the non-defect picture by a full connection module to determine whether the optimized differential encoded reconstructed picture is the non-defect picture.
[0023] Preferably, in step S5, the loss function comprises a differential encoder loss, a generator loss and a discriminator loss; the differential encoder loss comprises a KL divergence loss and a reconstruction loss, the reconstruction loss being a difference value between a reconstructed picture of the optimized differential encoding and the defect-free picture; the generator loss comprises a difference value between the intermediate feature of the differential encoding and the intermediate feature of the defect-free picture, and a difference value between the intermediate feature of the optimized differential encoding and the intermediate feature of the defect-free picture; and the discriminator loss is a discrimination of the reconstructed picture as a defect picture.
[0024] Preferably, the differential encoder and the discriminator each comprise a down-sampling module and a full connection module connected in sequence, the down-sampling module comprises a plurality of down-sampling layers connected in sequence, the down-sampling layer comprises a convolution unit, a BN unit and an activation function unit connected in sequence; the generator comprises a full connection module and an up-sampling module connected in sequence, the up-sampling module comprises a plurality of up-sampling layers connected in sequence, the up-sampling layer comprises a de-convolution unit, a BN unit and an activation function unit connected in sequence; and the full connection module in the differential encoder, the discriminator and the generator each comprises a plurality of full connection layers connected in sequence.
[0025] A defect detection network model training system based on the above-mentioned defect detection network model training method, comprising a collection module, a differential encoder module, a generator module, a discriminator module and a training module connected in sequence, the training module is further connected with the differential encoder module and the generator module respectively;
[0026] The collection module is used for collecting a defect-free picture sample set.
[0027] The differential encoder module is used for encoding the defect-free picture to obtain a differential encoding picture.
[0028] The generator module is used for reconstructing the differential encoding picture to obtain a reconstructed picture.
[0029] The discriminator module is used for discriminating whether the reconstructed picture is a defect-free picture.
[0030] The training module is used for calculating a corresponding loss function to train the differential encoder, the generator and the discriminator.
[0031] A defect detection method, comprising the steps of:
[0032] A, inputting a to-be-detected picture;
[0033] B, using the defect detection network model obtained by the above-mentioned training method to encode and reconstruct the to-be-detected picture to obtain a reconstructed picture;
[0034] C, calculating a structural similarity value of the reconstructed picture and the to-be-detected picture;
[0035] D, judging whether the to-be-detected picture has defects based on the structural similarity value.
[0036] As preferred, after step D, further comprising a step: if it is judged that the to-be-detected picture has defects, then based on the residual calculation result of the reconstructed picture and the to-be-detected picture, the to-be-detected picture is positioned for defects.
[0037] The beneficial technical effects of the present application include:
[0038] 1. The trained network model is made more stable, easy to train, and not prone to mode collapse by the combination of the differential encoder and the generator, so that the defect detection is more accurate, the reconstructed picture of the network model is made clearer by the combination of the generator and the discriminator, and the effect of defect detection in industrial production is improved by the combination of the differential encoder, the generator and the discriminator.
[0039] 2. The multi-scale information is extracted and fused by the multi-scale feature fusion module and the feature extraction module, the low-latitude features and high-latitude features are fused and compressed, the redundant information is removed while the features are enriched, the performance of the generator and the discriminator is improved, and the defect detection efficiency is improved to suppress the generalization ability of the network model.
[0040] 3. In the process of defect detection using the trained network model, if the to-be-detected picture has defects, since the defect area of the to-be-detected picture cannot be reconstructed during reconstruction, the residual calculation result of the reconstructed picture and the to-be-detected picture can realize accurate positioning of unknown defects. BRIEF DESCRIPTION OF DRAWINGS
[0041] Figure 1 A defect detection network model training method flowchart of the present application;
[0042] Figure 2 A defect detection method flowchart of the present application;
[0043] Figure 3 A SSIM distribution diagram of defect pictures and defect-free pictures in the defect detection process of the present application;
[0044] Figure 4 A reconstructed picture and a defect picture of the end face of the third roller in Example Three of the present application;
[0045] Figure 5 A reconstructed picture and a defect picture of the side face of the third roller in Example Three of the present application. DETAILED DESCRIPTION
[0046] The present application will be further described in detail below in combination with the drawings and examples.
[0047] Example One:
[0048] Referring to Figure 1 The embodiment provides a defect detection network model training method, including the steps of:
[0049] S1, the embodiment collects picture sample sets of drum-shaped rollers in industrial production, including end face sample sets, side face sample sets and chamfer data sets, extracts a region of interest, and cuts the region of interest into pictures with a size specification of 128x128. Taking the end face data set as an example, the end face data set is divided into defect-free pictures and defective pictures, wherein the defect-free pictures are denoted as X, the defect-free pictures with the size specification of 128x128 are trained in batches, and data normalization preprocessing is performed on the defect-free pictures according to the following calculation formula to obtain real pictures denoted as x.
[0050] x=(X / 255.0-mean) / std
[0051] Wherein mean and std are the mean and variance of the end face data set.
[0052] S2, the network architecture of the difference encoder encoder includes a down-sampling module and a full connection module connected in sequence, the down-sampling module includes four down-sampling layers connected in sequence, each down-sampling layer includes a convolution unit, a BN unit and an activation function unit connected in sequence, and the full connection module includes three full connection layers connected in sequence. The role of the convolution unit is feature extraction, which reduces the width and height of the input data of the previous down-sampling layer by half while increasing the number of channels and the number of feature maps. The role of the BN unit is to normalize each channel, calculate the mean of the width and height, accelerate the convergence of the model, and keep the independence between each feature of the defect-free picture. The activation function unit, the embodiment selects the ReLU function, the role is to give all negative values processed by the BN unit a non-zero slope, so that the network model can arbitrarily approximate any nonlinear function, and increase the nonlinear expression ability of the network model.
[0053] In this embodiment, the convolution unit adopts 5x5 convolution kernel f, the step length stride is 2, and the padding is 2. The convolution is used for down-sampling, which reduces the width and height of the defect-free picture by half, and increases the number of channels and the number of feature maps. After the picture sequentially passes through the four down-sampling layers, the first feature map is obtained, and the size of the first feature map is 8x8. Then, a full connection layer is used to convert the first feature map into a vector with a length of 2048, and two full connection layers are used to obtain the standard deviation (σ1, σ2, σ3…σn) and the mean value (μ1, μ2, μ3…μn) of a plurality of normal distributions. If random sampling is directly performed from N(μ, σ2), it is not derivable in the process of back propagation, and back propagation cannot be performed. Here, the re-parameterization idea is used to sample an ε from N(0, 1), and then Z = μ + ε * σ is calculated to sample the difference coding picture code(Z1, Z2, Z3…Zn), which is recorded as Zr. The difference coding picture code(Z1, Z2, Z3…Zn) is obtained by sampling from N(μ, σ2) and is derivable. The calculation formula is: σ = encoder(x), μ = encoder(x), and Z = μ + ε * σ.
[0054] S3, the network structure of the embedded structure includes a multi-scale feature fusion module MFF and a feature extraction module OCE. The low-dimensional features contain a lot of texture, edge and other information, and the high-dimensional features contain a lot of semantic structure and other information. Therefore, the multi-scale feature fusion module simultaneously fuses high-dimensional and low-dimensional information, extracts features of different scales through different sizes of convolution kernels, plays a role in feature fusion, and lays a foundation for normal reconstruction. The feature extraction module plays a role in feature compression, removal of redundant information and information bottleneck. The embedded structure plays a role in transition. If the picture information processed by the difference encoder is directly input to the generator without processing, there will be a lot of redundant information in the semantic structure, which will make it difficult for the generator to reconstruct, and at the same time, it will also make it difficult for the network to recover the most critical information. Therefore, the feature extraction module compresses the features on the basis of multi-scale feature fusion, enriches the information, and removes the redundant information as much as possible, and suppresses the overfitting of the network model.
[0055] The outputs f2, f3, f4 of the second, third and fourth down-sampling layers of step S2 are input into the network structure of the embedded structure. In order to make the feature dimensions the same, one or more convolution kernels with a size of 3x3 and a step length of 2 are applied to the high-dimensional features, and a BN unit and an activation function unit are connected to obtain a second feature map of feature fusion, wherein the activation function unit is a leaky rectified linear unit (Leaky ReLU), also known as a modified linear unit. After the feature dimensions are the same, a concatenation operation is performed, and the input is input into the feature extraction module. A 1x1 convolution kernel is used to reduce the number of channels to compress the features and remove redundant information, so as to obtain an optimized difference coding picture, which is recorded as Zo.
[0056] S4, the network architecture of the generator decoder includes a fully connected module and an up-sampling module connected in sequence, the up-sampling module includes four up-sampling layers connected in sequence, and the up-sampling layer includes a deconvolution unit, a BN unit and an activation function unit connected in sequence. The role of the deconvolution unit is to map low-dimensional features to high-dimensional features, which is opposite to the convolution unit operation in the differential encoder, and the roles of the BN unit and the activation function unit are the same as those of the corresponding units in the differential encoder.
[0057] The input parameters of the generator are three, one is the differential encoded picture Zr, the second is the optimized differential encoded picture Zo, and the third is random noise conforming to the Gaussian normal distribution, denoted as Zf. The input picture is processed by the fully connected module of the generator to obtain a third feature map with a feature size of 8x8. The third feature map passes through four up-sampling layers in sequence, wherein the convolution kernel of the deconvolution unit ConvTranspose2d is 6x6, the step is 2, and the padding is 2, to obtain a picture with a size of 3x128x128: the differential encoded reconstructed picture Pr, Pr=decoder(Zr), the optimized differential encoded reconstructed picture Po, Po=decoder(Zo), and the reconstructed picture of random noise, denoted as Pf, Pf=decoder(Zf).
[0058] S5, the network architecture of the discriminator discrim includes a down-sampling module and a fully connected module connected in sequence, the down-sampling module includes four down-sampling layers connected in sequence, each down-sampling layer includes a convolution unit, a BN unit and an activation function unit connected in sequence, and the fully connected module includes two fully connected layers connected in sequence.
[0059] The input parameters of the discriminator are three, one is the differential encoded reconstructed picture Pr, the second is the optimized differential encoded reconstructed picture Po, and the third is the real picture x. The convolution kernel size of the convolution unit is 5x5, the step is 2, and the padding is 2, and the features after the fourth down-sampling layer are taken as intermediate features to obtain the differential encoded intermediate features feature_r, feature_r=discrim(Pr), the optimized differential encoded intermediate features feature_o, feature_o=discrim(Po), and the intermediate features of the real picture feature_x, feature_x=discrim(x). The optimized differential encoded intermediate features and the intermediate features of the defect-free picture are discriminated by the fully connected module to determine whether the optimized differential encoded reconstructed picture is a defect-free picture or a defective picture. Through the continuous game between the generator and the discriminator, the reconstructed picture of the generator is more and more close to the defect-free picture until the discriminator determines that the result is a defect-free picture within a preset number of times.
[0060] S6, repeating the iteration of steps S2-S5 and calculating the corresponding loss functions to train the differential encoder, the generator and the discriminator until the discrimination result of the discriminator is the non-defect picture within a preset number of times, and then obtaining a defect detection network model including the trained differential encoder and the generator. The loss functions include a differential encoder loss, a generator loss and a discriminator loss. The loss functions are associated with optimization problems, and the network model is optimized and trained by minimizing the loss functions.
[0061] Differential encoder loss LOSS encoder including KL divergence loss and reconstruction loss LOSS Econ . The KL divergence loss is denoted as LOSS KL , and the KL divergence has great asymmetry. The reconstruction loss LOSS Econ is the difference value between the reconstructed picture of the optimized differential encoding and the real picture, which is measured by the L1 norm, LOSS Econ =||x-Pr||1, and the calculation formula is LOSS encoder =LOSS KL +LOSS Econ .
[0062] Generator loss LOSS decoder includes three parts, one is the difference between the intermediate feature feature_r of the differential encoding and the intermediate feature feature_x of the real picture, which is measured by the L2 norm, ||feature_r-feature_x||2, the second is the difference between the intermediate feature feature_o of the optimized differential encoding and the intermediate feature feature_x of the real picture, which is measured by the L2 norm, ||feature_o-feature_x||2, and the third is the reconstruction error LOSS gdis between the picture reconstructed by the generator from the random noise vector conforming to the Gaussian normal distribution and the real picture.
[0063] The calculation formula is: LOSS decoder =||feature_r-feature_x||2+||feature_o-feature_x||2+LOSS gdis .
[0064] Discriminator loss LOSS discrim is to discriminate the reconstructed picture as a defect picture, and the determination method is cross entropy.
[0065] The loss function calculation formula is: LOSS = LOSS encoder +LOSS decoder +LOSS discrim .
[0066] Embodiment two:
[0067] The embodiment provides a defect detection network model training system based on the defect detection network model training method in embodiment one, and the system comprises a collection module, a differential encoder module, a generator module, a discriminator module and a training module which are sequentially connected, and the training module is further connected with the differential encoder module and the generator module.
[0068] The collection module is used for collecting a set of defect-free picture samples.
[0069] The differential encoder module is used for encoding the defect-free pictures to obtain differential encoded pictures.
[0070] The generator module is used for reconstructing the differential encoded pictures to obtain reconstructed pictures.
[0071] The discriminator module is used for discriminating whether the reconstructed pictures are defect-free pictures.
[0072] The training module is used for calculating corresponding loss functions to train the differential encoder, the generator and the discriminator.
[0073] Embodiment three:
[0074] Referring to Figure 2 The embodiment provides a defect detection method, which comprises the following steps:
[0075] A, inputting a set of to-be-detected picture samples of drum-shaped rollers in industrial production, the set of to-be-detected picture samples comprising three parts, i.e., a chamfer, a side surface and an end surface, and the set of to-be-detected picture samples being divided into defect pictures and defect-free pictures.
[0076] B, using a defect detection network model obtained by using the training method in embodiment one to code and reconstruct the to-be-detected pictures to obtain reconstructed pictures.
[0077] C, calculating a structural similarity value SSIM of the reconstructed pictures and the to-be-detected pictures. The structural similarity SSIM comprises three contrast functions, i.e., a luminance contrast function, a contrast contrast function and a structural contrast function, and specific expressions are as follows:
[0078] Luminance contrast function:
[0079]
[0080]
[0081] Contrast contrast function:
[0082]
[0083]
[0084] Structural comparison function:
[0085]
[0086] Finally, the above three comparison functions constitute the SSIM function:
[0087] SSIM(x, y) = [l(x, y)] a [c(x, y)] β [s(x, y)] γ .
[0088] D, based on the structural similarity value SSIM, determine whether the to-be-detected picture has defects.
[0089] Further, referring to Figure 3 , steps A to C are repeatedly executed multiple times until 1500 defect-free pictures and 1500 defective pictures are selected, and the approximate range of the SSIM values of the 1500 defect-free pictures and the 1500 defective pictures is counted. A threshold value is selected from the approximate range to distinguish the two types of defect-free pictures and defective pictures as much as possible, and the threshold value is used as a preset threshold value for determining whether the to-be-detected picture is a defective picture.
[0090] Determine the binary classification of the product. If the SSIM is greater than the preset threshold value, the to-be-detected picture is a defect-free picture. If the SSIM is greater than the preset threshold value, the to-be-detected picture is a defective picture. The defect detection result of the embodiment shows that the trained defect detection network model has certain improvement effect on the accuracy of defect detection.
[0091] Further, after step D is performed, if the SSIM is greater than the preset threshold value and the to-be-detected picture is a defective picture, the residual calculation result based on the reconstructed picture and the defective picture is used to locate the defect of the defective picture. The difference between the defective picture and the reconstructed picture is used to accurately locate the defect position.
[0092] Referring to Figures 4-5 , Figure 4 The reconstructed picture and the defective picture of the roller end face of the embodiment are Figure 5 The reconstructed picture and the defective picture of the roller side face of the embodiment are shown in the table. The first row is the reconstructed picture, and the second row is the defective picture. In the defect detection stage, the reason why the defect area of the defective picture cannot be reconstructed is used to realize accurate positioning of the defect.
[0093] The applicant of the present application has made detailed description and illustration on the embodiments of the present application in combination with the drawings of the present application. However, those skilled in the art should understand that the above embodiments are only the preferred embodiments of the present application, and the detailed description is only for helping the readers to better understand the spirit of the present application, and is not intended to limit the protection scope of the present application. On the contrary, any improvement or modification based on the spirit of the present application should fall within the protection scope of the present application.
Claims
1. A method for training a defect detection network model, the method comprising: The method comprises the steps of: S1, collecting a set of defect-free picture samples; S2, encoding the defect-free pictures through a differential encoder to obtain differential encoded pictures; S3, reconstructing the differential encoded pictures through a generator to obtain reconstructed pictures; S4, determining whether the reconstructed pictures are defect-free pictures through a discriminator; S5, repeating the steps S2-S4 and calculating corresponding loss functions to train the differential encoder, the generator and the discriminator until the determination results of the discriminator are all defect-free pictures within a preset number of times, and then obtaining a defect detection network model comprising the trained differential encoder and the generator; In step S2, the method comprises the steps of: S2.1, performing convolution processing on the defect-free pictures through a downsampling module to obtain first feature maps; S2.2, performing convolution processing on the first feature maps through a fully connected module to obtain a standard deviation of a normal distribution and a mean value of the normal distribution; S2.3, calculating the differential encoded pictures based on the standard deviation of the normal distribution and the mean value of the normal distribution; Between step S2 and step S3, the method further comprises the steps of: inputting the differential encoded pictures into a multi-scale feature fusion module to perform multi-scale fusion on the features of different dimensions of the differential encoded pictures to obtain second feature maps of feature fusion, and inputting the second feature maps of feature fusion into a feature extraction module after splicing to obtain optimized differential encoded pictures; In step S3, the method comprises the steps of: S3.1, processing the differential encoded pictures and the optimized differential encoded pictures through a fully connected module to obtain third feature maps; and 2. The method of claim 1, wherein, S3.2, reconstructing the third feature maps through an upsampling module to obtain differential encoded reconstructed pictures and optimized differential encoded reconstructed pictures. In step S4, the method comprises the steps of: S4.1, performing convolution processing on the differential encoded reconstructed pictures, the optimized differential encoded reconstructed pictures and the defect-free pictures through a downsampling module to obtain intermediate features of differential encoding, intermediate features of optimized differential encoding and intermediate features of the defect-free pictures; 3. The method of claim 2, wherein, S4.2, discriminating the intermediate features of optimized differential encoding and the intermediate features of the defect-free pictures through a fully connected module to determine whether the optimized differential encoded reconstructed pictures are defect-free pictures. In step S5, the loss function comprises a differential encoder loss, a generator loss and a discriminator loss; the differential encoder loss comprises a KL divergence loss and a reconstruction loss, and the reconstruction loss is a difference value between the optimized differential encoded reconstructed pictures and the defect-free pictures; the generator loss comprises a difference value between the intermediate features of differential encoding and the intermediate features of the defect-free pictures and a difference value between the intermediate features of optimized differential encoding and the intermediate features of the defect-free pictures; and the discriminator loss is a determination result of determining the reconstructed pictures as defect pictures.
4. The method of claim 1, wherein, The differential encoder and the discriminator each comprise a down-sampling module and a full connection module connected in sequence, the down-sampling module comprises a plurality of down-sampling layers connected in sequence, the down-sampling layer comprises a convolution unit, a BN unit and an activation function unit connected in sequence; the generator comprises a full connection module and an up-sampling module connected in sequence, the up-sampling module comprises a plurality of up-sampling layers connected in sequence, the up-sampling layer comprises a de-convolution unit, a BN unit and an activation function unit connected in sequence; the full connection modules in the differential encoder, the discriminator and the generator each comprise a plurality of full connection layers connected in sequence.
5. A system for training a defect detection network model based on the method of any one of claims 1-4, characterized in that, The method comprises the following steps: The acquisition module is configured to acquire a set of defect-free image samples; The differential encoder module is configured to encode the defect-free images to obtain differential encoded images; The generator module is configured to reconstruct the differential encoded images to obtain reconstructed images; The discriminator module is configured to determine whether the reconstructed images are defect-free images; The training module is configured to calculate corresponding loss functions to train the differential encoder, the generator and the discriminator.
6. A defect detection method characterized by, The method comprises the following steps: A, inputting a to-be-detected image; B, using the defect detection network model obtained by the training method of any one of claims 1-4 to encode and reconstruct the to-be-detected image to obtain a reconstructed image; C, calculating the structural similarity value of the reconstructed image and the to-be-detected image; D, determining whether the to-be-detected image has defects based on the structural similarity value.
7. The defect detection method of claim 6, wherein, After step D is performed, the method further comprises the step of: if it is determined that the to-be-detected image has defects, performing defect positioning on the to-be-detected image based on the residual calculation result of the reconstructed image and the to-be-detected image.