Surface defect detection method based on feature reconstruction

Through feature reconstruction method, the defect generator and multi-scale feature generator are used to extract features, combined with self-coding and class twin networks, the problem that traditional image reconstruction methods cannot effectively detect complex defects, and high-quality defect detection and Rich feature extraction, enhancing detection capabilities and robustness.

CN114419014BActive Publication Date: 2024-12-10HEBEI ZEHUA WEIYE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210083931.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-19
Publication Date
2024-12-10
Estimated Expiration
2042-01-19

AI Technical Summary

Technical Problem

Traditional surface defect detection based on machine vision is difficult to accurately detect in complex industrial environments, especially because the defect area and background are small, the contrast is low, the defect scale changes are large and the types are diverse, and the image reconstruction method cannot effectively reconstruct defect images. Causes false defect alarms and poor detection results.

Method used

采用基于特征重构的方法,利用缺陷生成器模拟生成缺陷图像,通过多尺度特征生成器提取特征,结合自编码重构网络和类孪生网络,提取重构前后的特征差异,生成缺陷检测掩码图,并通过平均滤波器进行平滑处理,实现端到端的缺陷检测。

Benefits of technology

Improve the accuracy and robustness of defect detection, generate high-quality defect detection mask diagrams, avoid false alarms, realize defect samples generation without manual annotation and extract rich spatial information and semantic information, and enhance detection capabilities .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114419014B_ABST
    Figure CN114419014B_ABST
Patent Text Reader

Abstract

The present invention is a surface defect detection method based on feature reconstruction. First, a defect generator is used to simulate and generate a defect image on a normal image; the normal image and the defect image are respectively input into a multi-scale feature generator to extract the normal features corresponding to the normal image and the defect features corresponding to the defect image; then, the defect features are used as the input of the autoencoder reconstruction network, and the normal features are used as the reconstruction target of the autoencoder reconstruction network to reconstruct the defect features to obtain the reconstructed features; finally, the defect features and the reconstructed features are spliced ​​in the channel dimension to form a feature vector of two channels, and the spliced ​​features are then input into a quasi-twin network, and the quasi-twin network is used to extract the difference between the features before and after reconstruction for defect detection, and a defect detection mask is generated. The method is based on a feature reconstruction network with normal features as the reconstruction target, and uses a quasi-twin network to extract the difference between the features before and after reconstruction to generate a high-quality defect detection image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of machine vision defect detection, and in particular relates to a surface defect detection method based on feature reconstruction. Background Art

[0002] Surface defect detection is an important research branch in the field of machine vision. It is a technology that uses machine vision equipment to obtain images and determine whether there are defects in the images. Defects include cracks, spots, scratches and other types. Surface defect detection based on machine vision has widely replaced manual visual detection in various industrial fields. Traditional surface defect detection based on machine vision often uses conventional image processing algorithms or manually designed features plus classifiers. In real and complex industrial environments, surface defect detection often faces many challenges, such as small differences between defect areas and backgrounds, low contrast, large defect scale variations and various types, a large amount of noise in defect images, and a large amount of interference in the imaging of defects in natural environments. Therefore, traditional surface defect detection based on machine vision is difficult to achieve good detection results.

[0003] In recent years, as deep learning models represented by convolutional neural networks have been successfully applied in many fields such as face recognition, pedestrian re-identification, scene text detection, target tracking and autonomous driving, many deep learning-based defect detection methods have also been widely used in various industrial scenarios.

[0004] At present, unsupervised defect detection methods can be roughly divided into two categories: feature modeling and image reconstruction, according to the different defect detection mechanisms. Feature modeling-based methods are committed to constructing effective representations of the entire image or local areas by using hand-crafted features or representations learned through neural networks. Many machine learning models such as sparse coding, Gaussian mixture models, and Kmeans clustering can be used to establish the feature distribution of normal images. For defect detection, if the regional features corresponding to the local area of ​​the image to be detected deviate from the feature distribution established by the normal image, the local area will be marked as a defect.

[0005] The image reconstruction-based method uses a deep convolutional autoencoder to compress and reconstruct the input image. It first learns how to reconstruct a normal image, and then detects potential defects by evaluating the pixel difference between the input image and the reconstructed image. The pixel-level L2 distance and the image structural similarity metric (SSIM) can measure the difference before and after reconstruction. Usually, the detection method based on image reconstruction only trains the deep convolutional autoencoder on normal images, but does not extend to defective images. That is, it can only reconstruct normal images but not defective images.

[0006] It is very intuitive to use image reconstruction for defect detection. However, since image reconstruction detects potential defects by evaluating the differences between pixels in the image space, it is usually expected to generate high-quality images for comparison. Since the differences between images are reflected in properties such as brightness, contrast, and structure, the pixel difference between two images cannot accurately reflect the real difference between the images. In addition, image reconstruction usually has difficulty in reconstructing clear edges and complex texture structures of images, so edges or texture structures often have large reconstruction errors, resulting in a large number of false defect alarms. Summary of the invention

[0007] In view of the deficiencies in the prior art, the technical problem to be solved by the present invention is to provide a surface defect detection method based on feature reconstruction.

[0008] The technical solution adopted by the present invention to solve the technical problem is:

[0009] A surface defect detection method based on feature reconstruction, characterized in that the method specifically comprises the following steps:

[0010] Step 1: Use the defect generator to simulate and generate a defect image on a normal image;

[0011] Step 2: The normal image and the defect image are respectively input into the multi-scale feature generator to extract the normal features corresponding to the normal image and the defect features corresponding to the defect image;

[0012] Step 3: Take the defect features as the input of the self-encoding reconstruction network, take the normal features as the reconstruction target of the self-encoding reconstruction network, reconstruct the defect features, and obtain the reconstructed features;

[0013] Step 4: Concatenate the defect features and the reconstructed features in the channel dimension to form a feature vector of the two channels. The concatenated features are then input into the quasi-Siamese network. The quasi-Siamese network is used to extract the difference between the features before and after reconstruction for defect detection and generate a defect detection mask map. Finally, the defect detection mask map is smoothed using an average filter.

[0014] The entire process of surface defect detection based on feature reconstruction is now completed.

[0015] The autoencoder reconstruction network is composed of an encoder and a decoder. The encoder includes three encoder layers, each encoder layer corresponds to a decoder layer, that is, the decoder includes three decoder layers; the first encoder layer and the second encoder layer have the same structure, both including a convolution layer, batch normalization processing and nonlinear activation processing; the third encoder layer is composed of a convolution layer; the encoder convolves the defect features and compresses them into a low-dimensional latent space to perform a potential representation of the defect features;

[0016] The first decoder layer and the second decoder layer have the same structure, both of which include convolutional layers, batch normalization processing and nonlinear activation processing; the third decoder layer consists of a convolutional layer; the decoder decodes the output of the encoder, that is, reproduces the potential representation of the defect features.

[0017] The quasi-twin network includes a backbone structure and a top-level module as a decision layer, and the output of the backbone structure serves as the input of the top-level module; wherein the backbone structure includes an asymmetric encoding structure and a decoding structure, the encoding structure includes three convolution modules and two maximum pooling layers, each convolution module of the encoding structure includes a convolution operation, a batch normalization operation and an activation operation, and each convolution module performs the above operations twice; the two maximum pooling layers are respectively located after the second activation operation of the first two convolution modules; the decoding structure consists of four upsampling modules and four convolution modules, each upsampling module is connected to a convolution module, and the output of the previous convolution module serves as the input of the next upsampling module; each upsampling module includes a linear interpolation operation, a convolution operation, a normalization operation and an activation operation, each convolution module of the decoding structure includes a convolution operation, a normalization operation and an activation operation, and each convolution block performs the above operations twice; the top-level module consists of a decision layer of a convolution operation.

[0018] The multi-scale feature generator is a pre-trained deep convolutional neural network. The last three fully connected layers and a softmax layer of the deep convolutional neural network are removed, and only the backbone network of the deep convolutional neural network is retained; the backbone network uses the maxpool layer as the boundary, and all the convolutional layers of the backbone network are divided into five convolutional modules, and each convolutional module contains multiple convolutional layers; the multi-scale feature generator outputs and retains the features extracted from each convolutional layer, first adjusting the spatial dimensions of all features to be consistent, and keeping the channel dimension unchanged; then performing an attention feature fusion operation on all adjusted features in each convolutional module to obtain the fused features corresponding to the convolutional module; finally, the fused features corresponding to all convolutional modules are spliced ​​on the channel dimension to obtain multi-scale features.

[0019] The second step also includes the following:

[0020] For the same input image, the input image is first scaled at different ratios to obtain multiple input images with different resolutions; then, the multiple input images with different resolutions are respectively passed through a multi-scale feature generator to extract features of multiple scales; finally, the multiple features of different scales are spliced ​​in the channel dimension, and then multi-scale features are extracted from the input image; the input image is a normal image or a defective image.

[0021] The specific process of the attention feature fusion operation is as follows: for each convolution module, the output features of the first two convolution layers of the convolution module are first fused according to formula (2), and the fused features are then fused with the output features of the next convolution layer in the current convolution module according to formula (2), until all convolution layers in the convolution module are fused, and the fused features corresponding to the convolution module are obtained;

[0022]

[0023] Among them, X and Y are the two input features of the attention feature fusion operation, that is, the output features of the two convolutional layers. They represent addition and multiplication operations respectively, M represents the multi-scale channel attention fusion operation, and Z is the output of the attention feature fusion operation;

[0024] For each input feature of the multi-scale channel attention fusion operation, the following operations need to be performed:

[0025]

[0026] Among them, f represents the input features of multi-scale channel attention fusion, S represents the Sigmoid function, PWC represents the point-by-point convolution operation, R represents the ReLU function, and GAP represents the global average pooling operation.

[0027] In the first step, the specific process of generating defect images is as follows:

[0028] Firstly, a noise image is generated by Perlin noise, and the noise image is binarized to obtain a defect mask image;

[0029] Then, a defect texture image is selected from a defect image data set that is completely unrelated to the training data, and the defect texture image is enhanced; the enhanced defect texture image is multiplied by the defect mask image according to the pixel to obtain the defect area; at the same time, the defect mask image is inverted to obtain the defect mask inverse image; the defect mask inverse image is multiplied by the original normal image according to the pixel to obtain the normal area;

[0030] Finally, the defect area and the normal area are subjected to opacity enhancement processing respectively, and then added together to obtain the defect image.

[0031] Compared with the prior art, the advantages and beneficial effects of the present invention are:

[0032] (1) The present invention transfers the idea of ​​image reconstruction to the feature level, so that defect detection can achieve the maximum detection capability and generate a high-quality defect detection mask image; first, the defect features are extracted from the simulated defect image, and the defect features are used as the training guidance information of the autoencoder reconstruction network to ensure that the autoencoder reconstruction network reconstructs the defect features with normal features as the target, thus solving the problem that the reconstruction network cannot reconstruct the defect features into normal features due to the lack of supervision information guidance; then, a quasi-twin network is introduced to extract the difference between the features before and after reconstruction, realize the mapping of the difference between features to the difference between images, and transform the defect expression at the feature level into the defect expression in the image space, thus avoiding tedious post-processing and realizing end-to-end network optimization.

[0033] (2) The multi-scale feature generator proposed in the present invention is a pre-trained deep convolutional neural network. The multi-scale feature generator is used to extract features from the image and generate multi-scale features containing rich spatial information and semantic information, so that the multi-scale features have strong recognition power and are conducive to defect detection.

[0034] (3) The attention feature fusion operation locally aggregates the output features of all convolutional layers in each convolutional module, which enhances the correlation between the output features of each convolutional module and avoids the problem of relative independence of features caused by directly splicing the output features of all convolutional layers of the backbone network. The attention feature fusion operation can not only ensure that the generated multi-scale features contain rich spatial and semantic information, but also ensure that the multi-scale feature dimensions are kept at a small level, which will not cause great computational pressure on computing resources.

[0035] (4) By simulating and generating defect images, a method for generating defect samples without manual labeling is provided, which to a certain extent solves the problem that supervised defect detection cannot be performed due to limited or unavailable defect samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 It is the overall flow chart of the present invention;

[0037] Figure 2 is a flow chart of a defect generator of the present invention;

[0038] Figure 3 is a flow chart of a multi-scale feature generator of the present invention;

[0039] Figure 4 It is a structural diagram of the twin-like network of the present invention;

[0040] Figure 5 This is a result diagram of defect detection using the present invention. DETAILED DESCRIPTION

[0041] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings and embodiments, but the protection scope of the present application is not limited thereto.

[0042] The present invention is a surface defect detection method based on feature reconstruction (hereinafter referred to as the method), which specifically comprises the following steps:

[0043] Step 1: Use the defect generator to simulate and generate a defect image on a normal image;

[0044] Figure 2 This is the flow chart of the defect generator. First, a noise image is generated by Perlin noise, and the noise image is binarized using a random uniform sampling threshold to obtain a defect mask image.

[0045] Then, a defect texture image is selected from a defect image data set that is completely unrelated to the training data, and the defect texture image is enhanced; the enhanced defect texture image is multiplied by the defect mask image pixel by pixel to obtain the defect area; the enhancement processing includes any three of color adjustment, sharpness, sunlight, balance, brightness change, color change, and automatic contrast. The enhancement processing can generate images of different defects based on an image of a single defect to ensure the diversity of defects;

[0046] At the same time, the defect mask image is inverted to obtain an inverse defect mask image; the inverse defect mask image is multiplied by the original normal image pixel by pixel to obtain a normal area;

[0047] Finally, the defect area and the normal area are processed with opacity enhancement respectively, and then added to obtain the defect image. The defect image generated by simulation helps to tighten the decision boundary in the training network and better realize defect detection; defect image I a Defined as:

[0048]

[0049] Among them, M a is the defect mask image, is the defect mask inverse image, I is the original normal image, ⊙ represents the pixel multiplication operation, A is the defect texture image; β is the opacity parameter, which is uniformly sampled in the set interval, for example, β∈[0.1,1].

[0050] Step 2: The normal image and the defect image obtained in the first step are respectively input into the multi-scale feature generator to extract the normal features corresponding to the normal image (hereinafter referred to as normal features) and the defect features corresponding to the defect image (hereinafter referred to as defect features) respectively;

[0051] The multi-scale feature generator is a pre-trained deep convolutional neural network VGG. The last three fully connected layers and a softmax layer of the VGG network are removed, and only the backbone network of the VGG network is retained as the multi-scale feature generator for feature extraction in this method. The backbone network is divided into five convolutional modules with the maxpool layer as the boundary, and each convolutional module contains multiple convolutional layers. The multi-scale feature generator outputs and retains the features extracted from each convolutional layer. First, the spatial dimensions of all features are adjusted to be consistent, and the channel dimension remains unchanged. Then, all the adjusted features in each convolutional module are fused with attention features to obtain the fused features corresponding to the convolutional module. Finally, the fused features corresponding to all convolutional modules are spliced ​​in the channel dimension to generate multi-scale features.

[0052] In this embodiment, the multi-scale feature generator uses VGG-19. The backbone network of VGG-19 contains a total of 16 convolutional layers. The 16 convolutional layers are divided into five convolutional modules with the maxpool layer as the boundary. The first two convolutional modules each contain two convolutional layers, and the last three convolutional modules each contain four convolutional layers.

[0053] The second step also includes the following:

[0054] The multi-scale feature generator adopts a feature generation scheme of multi-resolution input and multi-scale output. For the same input image, the input image is first scaled at different ratios to obtain multiple input images with different resolutions; then, the multiple input images with different resolutions are respectively extracted by the multi-scale feature generator to obtain features of multiple scales; finally, the features of multiple scales are spliced ​​in the channel dimension to finally obtain the multi-scale features extracted from the input image; the input image is a normal image or a defective image;

[0055] The specific process of the attention feature fusion operation is as follows: for each convolution module, the output features of the first two convolution layers of the convolution module are first fused according to formula (2), and the fused features are then fused with the output features of the next convolution layer in the current convolution module according to formula (2), until all convolution layers in the convolution module are fused, and the fused features corresponding to the convolution module are obtained;

[0056]

[0057] Among them, X and Y are the two input features of the attention feature fusion operation, that is, the output features of the two convolutional layers. They represent addition and multiplication operations respectively, M represents the multi-scale channel attention fusion operation, and Z is the output of the attention feature fusion operation;

[0058] For each input feature of the multi-scale channel attention fusion operation, the following operations need to be performed:

[0059]

[0060] Among them, f represents the input features of multi-scale channel attention fusion, S represents the Sigmoid function, PWC represents the point-by-point convolution operation, R represents the ReLU function, and GAP represents the global average pooling operation;

[0061] Step 3: Use the defect features obtained in the second step as the input of the autoencoder reconstruction network, and use the normal features obtained in the second step as the reconstruction target of the autoencoder reconstruction network to reconstruct the defect features and obtain the reconstructed features; during the reconstruction process, the L2 function is used to calculate the loss of the autoencoder reconstruction network. The expression of the L2 function is:

[0062]

[0063] Among them, h0 and w0 are the height and width of the feature space dimension, i and j are the spatial position coordinates, and y i,j (x), y i ' ,j (x) are the normal features and reconstructed features corresponding to the defect features before reconstruction;

[0064] The autoencoder reconstruction network is composed of an encoder and a decoder, which is a symmetrical encoding-decoding structure, which is used to convert the local pattern of the input image into a pattern closer to the normal sample distribution. Therefore, the autoencoder reconstruction network has a normal recovery characteristic; the encoder contains three encoder layers, each encoder layer corresponds to a decoder layer, that is, the decoder contains three decoder layers; the structure of the first encoder layer and the second encoder layer is the same, both of which include a convolution layer, batch normalization processing and nonlinear activation processing, and the nonlinear activation processing uses the ReLU function; the third encoder layer is composed of a convolution layer; the encoder convolves the defect features and compresses them into a low-dimensional latent space to potentially represent the defect features; for the dimension C of the low-dimensional latent representation d The method adopts the principal component analysis (PCA) method. First, a feature subset of a region is randomly extracted from the defect features. Then, the PCA method is used to estimate the potential dimension. The PCA estimation result is used as the dimension C of the low-dimensional potential representation. d , thus maintaining 90% of the variance;

[0065] The first decoder layer and the second decoder layer have the same structure, both of which include convolutional layers, batch normalization processing, and nonlinear activation processing. The nonlinear activation processing uses the ReLU function. The third decoder layer consists of a convolutional layer. The decoder decodes the output of the encoder, that is, reproduces the potential representation of the defect feature.

[0066] Step 4: Concatenate the defect features and the reconstructed features in the channel dimension to form a feature vector of the two channels. The concatenated features are then input into the quasi-twin network, and the quasi-twin network is used for defect detection. The quasi-twin network extracts the difference between the defect features and the reconstructed features to generate a defect detection mask map.

[0067] like Figure 4 As shown, the quasi-twin network includes a backbone structure and a top-level module as a decision layer, and the output of the backbone structure serves as the input of the top-level module; wherein, the backbone structure includes an asymmetric encoding structure and a decoding structure, the encoding structure includes three convolution modules and two maximum pooling layers, each convolution module of the encoding structure includes a convolution operation, a batch normalization operation and an activation operation, and each convolution module performs the above operations twice; the two maximum pooling layers are respectively located after the second activation operation of the first two convolution modules; the decoding structure consists of four upsampling modules and four convolution modules, each upsampling module is connected to a convolution module, and the output of the previous convolution module serves as the input of the next upsampling module; each upsampling module includes a linear interpolation operation, a convolution operation, a normalization operation and an activation operation, each convolution module of the decoding structure includes a convolution operation, a normalization operation and an activation operation, and each convolution block performs the above operations twice; the top-level module consists of a decision layer of a convolution operation;

[0068] The loss of defect detection is calculated using the Focal Loss function of formula (5) to optimize the quasi-Siamese network;

[0069] FL(p t )=-α t (1-p t ) r log(p t ) (5)

[0070] Among them, p t Indicates the probability that the predicted sample belongs to 1, α t represents the positive and negative sample control parameters, r represents the difficult sample modulation parameter;

[0071] Finally, the defect detection mask image is smoothed by using an average filter to aggregate the local abnormal response information in the defect detection mask image and perform edge processing on the defect detection mask image. At the same time, the maximum value of the smoothed defect score image is selected according to formula (6) to calculate the final image-level defect score η. The image-level defect score η is used as the image-level defect classification result. If the image-level defect score is greater than the set threshold, the input image can be judged as a defective image.

[0072] η=max(M0*g n×n ) (6)

[0073] Among them, M0 represents the defect detection mask image, g n×n represents an average filter of size n×n, and * represents a convolution operator.

[0074] Due to the normal recovery characteristics of the autoencoder reconstruction network, for the same defect image, there are significant differences between the defect features and the reconstructed features, providing necessary information for defect detection; the defect features are compared with the reconstructed features through the quasi-twin network to learn the difference between the two. The quasi-twin network can automatically learn the appropriate distance measurement between the defect features and the reconstructed defect features, which can avoid the problem that the similarity measurement of surface defect detection is difficult to design manually. The defect detection mask output by the quasi-twin network is a pixel-level image, which can directly interpret the defects and perform image-level defect score estimation.

[0075] Figure 5 The defect detection result map using the method of the present invention follows the principle of preferring false detection to missed detection, so a smaller threshold is preferred, which will result in the predicted defect area being larger than the actual defect area. In addition, since the method finally uses an average filter to smooth the defect detection mask map, the local defect response information in the defect detection mask map is aggregated, thereby further increasing the defect area in the predicted result mask map. Figure 5 The test results show that this method can accurately detect different defects, which shows the superiority of this method in defect detection. Figure 5 In the E-th column of images, there is a small white dot defect area in the original image. This defect is not reflected in the real annotated image, but this method can accurately detect the small white dot defect area, indicating that this method has a good detection effect in small target defect detection.

[0076] Any matters not described in the present invention are applicable to the prior art.

Claims

1. A surface defect detection method based on feature reconstruction, It is characterized in that The method specifically comprises the following steps: Step 1: Use the defect generator to simulate and generate a defect image on a normal image; Step 2: The normal image and the defect image are respectively input into the multi-scale feature generator to extract the normal features corresponding to the normal image and the defect features corresponding to the defect image; Step 3: Take the defect features as the input of the self-encoding reconstruction network, take the normal features as the reconstruction target of the self-encoding reconstruction network, reconstruct the defect features, and obtain the reconstructed features; Step 4: Concatenate the defect features and the reconstruction features in the channel dimension to form a feature vector of the two channels. The concatenated features are then input into the quasi-twin network. The quasi-twin network is used to extract the difference between the features before and after reconstruction for defect detection, and a defect detection mask map is generated. The quasi-twin network includes a backbone structure and a top-level module as a decision layer, and the output of the backbone structure is used as the input of the top-level module. The backbone structure includes an asymmetric encoding structure and a decoding structure. The encoding structure includes three convolution modules and two maximum pooling layers. Each convolution module of the encoding structure includes a convolution operation, a batch normalization operation, and an activation operation. Each convolution module is executed twice. The above operations; two maximum pooling layers are located after the second activation operation of the first two convolution modules respectively; the decoding structure consists of four upsampling modules and four convolution modules, each upsampling module is connected to a convolution module, and the output of the previous convolution module is used as the input of the next upsampling module; each upsampling module contains linear interpolation operation, convolution operation, normalization operation and activation operation, and each convolution module of the decoding structure includes convolution operation, normalization operation and activation operation, and each convolution block performs the above operations twice; the top module consists of a decision layer of convolution operation; finally, the defect detection mask map is smoothed by using an average filter; The entire process of surface defect detection based on feature reconstruction is now completed.

2. The surface defect detection method based on feature reconstruction according to claim 1, It is characterized in that The autoencoder reconstruction network is composed of an encoder and a decoder. The encoder includes three encoder layers, each encoder layer corresponds to a decoder layer, that is, the decoder includes three decoder layers; the first encoder layer and the second encoder layer have the same structure, both including a convolution layer, batch normalization processing and nonlinear activation processing; the third encoder layer is composed of a convolution layer; the encoder convolves the defect features and compresses them into a low-dimensional latent space to perform a potential representation of the defect features; The first decoder layer and the second decoder layer have the same structure, both of which include convolutional layers, batch normalization processing and nonlinear activation processing; the third decoder layer consists of a convolutional layer; the decoder decodes the output of the encoder, that is, reproduces the potential representation of the defect features.

3. The surface defect detection method based on feature reconstruction according to claim 1, It is characterized in that The multi-scale feature generator is a pre-trained deep convolutional neural network. The last three fully connected layers and a softmax layer of the deep convolutional neural network are removed, and only the backbone network of the deep convolutional neural network is retained; the backbone network is divided into five convolutional modules with the maxpool layer as the boundary, and each convolutional module contains multiple convolutional layers; The multi-scale feature generator outputs and retains the features extracted by each convolution layer. First, the spatial dimensions of all features are adjusted to be consistent, and the channel dimension remains unchanged. Then, the attention feature fusion operation is performed on all the adjusted features in each convolution module to obtain the fused features corresponding to the convolution module. Finally, the fused features corresponding to all convolution modules are spliced ​​on the channel dimension to obtain multi-scale features.

4. The surface defect detection method based on feature reconstruction according to claim 3, It is characterized in that The second step also includes the following: For the same input image, the input image is first scaled at different ratios to obtain multiple input images with different resolutions; then, the multiple input images with different resolutions are respectively passed through a multi-scale feature generator to extract features of multiple scales; finally, the multiple features of different scales are spliced ​​in the channel dimension, and then multi-scale features are extracted from the input image; the input image is a normal image or a defective image.

5. The surface defect detection method based on feature reconstruction according to claim 3 or 4, It is characterized in that The specific process of the attention feature fusion operation is as follows: for each convolution module, the output features of the first two convolution layers of the convolution module are first fused according to formula (2), and the fused features are then fused with the output features of the next convolution layer in the current convolution module according to formula (2), until all convolution layers in the convolution module are fused, and the fused features corresponding to the convolution module are obtained; Among them, X and Y are the two input features of the attention feature fusion operation, that is, the output features of the two convolutional layers. Represent the addition operation and the multiplication operation respectively, M represents the multi-scale channel attention fusion operation, and Z is the output of the attention feature fusion operation; for each input feature of the multi-scale channel attention fusion operation, the following operations need to be performed: Among them, f represents the input features of multi-scale channel attention fusion, S represents the Sigmoid function, PWC represents the point-by-point convolution operation, R represents the ReLU function, and GAP represents the global average pooling operation.

6. The surface defect detection method based on feature reconstruction according to claim 1, It is characterized in that The specific process of generating defect images in the first step is: Firstly, a noise image is generated by Perlin noise, and the noise image is binarized to obtain a defect mask image; Then, a defect texture image is selected from a defect image data set that is completely unrelated to the training data, and the defect texture image is enhanced; the enhanced defect texture image is multiplied by the defect mask image according to the pixel to obtain the defect area; at the same time, the defect mask image is inverted to obtain the defect mask inverse image; Multiply the defect mask inverse image and the original normal image pixel by pixel to obtain the normal area; Finally, the defect area and the normal area are subjected to opacity enhancement processing respectively, and then added together to obtain the defect image.