A method for constructing a product surface defect detection model based on an autoencoder
By constructing a surface defect detection model based on an autoencoder-based reconstruction subnetwork and segmentation subnetwork, the problems of low efficiency and low accuracy of manual quality inspection in industrial product surface defect detection are solved, achieving efficient and accurate defect detection and location.
Patent Information
- Application Number
- CN202310619196.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-30
- Publication Date
- 2026-03-03
- Estimated Expiration
- 2043-05-30
AI Technical Summary
In existing technologies, the detection of surface defects in industrial products relies on manual quality inspection, which is inefficient and inaccurate, and there are omissions in the detection of small defects, making it difficult to achieve efficient automated detection.
A surface defect detection model is constructed using an autoencoder-based reconstruction subnetwork and segmentation subnetwork. Combined with a hybrid loss function and an efficient channel attention module, the product surface defect detection model is reconstructed through the autoencoder, and the anomaly localization segmentation map is directly output, avoiding additional manual preprocessing and postprocessing.
It improves the speed and accuracy of defect detection, enables accurate defect identification and location, reduces data preprocessing workload, and enhances detection capabilities.
Smart Images

Figure CN116778269B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for constructing a product surface defect detection model, and more particularly to a method for constructing a product surface defect detection model based on an autoencoder. Background Technology
[0002] In industrial production, incorrect production processes or unexpected situations such as scratches and bumps can leave abnormal areas such as scratches, damage, and dirt on the product surface. These structurally abnormal defect areas not only affect the appearance of the product but may also reduce its performance.
[0003] Industrial surface inspection is a crucial step in quality control during production, and its effectiveness often determines the value of a product. Therefore, inspecting these defective areas is a vital part of the industrial production process. Currently, appearance quality inspection in China's manufacturing industry is mainly done manually. However, manual inspection has several shortcomings. First, the working environment is generally poor; inspectors often have to work for extended periods under strong light and require high concentration, which can lead to severe vision problems. Second, when defects are smaller than 0.5mm and have no significant optical deformation, the human eye cannot detect them. Furthermore, the accuracy of manual inspection is inconsistent and easily affected by the inspector's condition, leading to missed defects and low efficiency. Therefore, more efficient automated inspection systems are needed to replace manual labor in industrial appearance quality inspection. Summary of the Invention
[0004] The purpose of this invention is to provide a method for constructing a product surface defect detection model based on an autoencoder. This method can directly output an accurate anomaly localization segmentation map by inputting the image to be tested, avoiding additional manual preprocessing and postprocessing, increasing the overall fit of the model, improving the detection speed, obtaining the maximum detection capability, effectively improving the speed and accuracy of defect detection, and achieving accurate defect identification and localization.
[0005] The present invention adopts the following technical solution:
[0006] A method for constructing a product surface defect detection model based on an autoencoder reconstruction, the method comprising the following steps:
[0007] S1, collect and organize various industrial product datasets;
[0008] S2, Design an anomaly generation module that can simulate and generate defect samples;
[0009] S3 utilizes an autoencoder-based reconstruction subnetwork and a U-net-like segmentation subnetwork to construct a surface defect detection model;
[0010] S4, The simulated defect samples are used to train the defect detection model, and the model's loss function adopts a hybrid loss function;
[0011] S5. Input the sample to be tested into the defect detection model, reconstruct the defect image, and compare it with the original sample to obtain the anomaly localization and segmentation result.
[0012] The method for constructing a product surface defect detection model based on an autoencoder includes the following steps in step S2:
[0013] S21, the noisy image P is generated by a Berlin noise generator to capture various anomalous shapes, and binarized using a threshold T (T = 0.5) with random uniform sampling to form an anomalous mask image P. m ;
[0014] S22, using the Otsu method to distinguish the foreground and background of industrial products by maximizing the inter-class variance, the input image I is binarized and segmented to obtain the mask I. m Next, two masks P are used. m and I m Element-wise multiplication yields the mask image M;
[0015] M = P m ⊙I m
[0016] S23, the abnormal texture source image D is sampled from an abnormal source dataset whose distribution is independent of the input image I. Simultaneously, to maintain the diversity of abnormal generation, three types of samples are randomly selected from the set {tone separation, sharpness, exposure enhancement, equalization, brightness variation, color variation, automatic contrast} for enhancement sampling from the abnormal source image D. The enhanced texture image D and the input image I are masked by a mask M and compared with the input image I. The masked input image I is blended to obtain the final simulated anomaly generated image I. A ;
[0017]
[0018] Where β is the opacity parameter during blending, following a random uniform distribution in the range [0.1, 1.0], and ⊙ represents the successive multiplication operation. It is P m The reverse of the original.
[0019] The method for constructing a product surface defect detection model based on an autoencoder reconstruction includes the following steps in step S3:
[0020] S31, construct a reconstruction sub-network based on an autoencoder, and add an efficient channel attention (ECA) module in the encoding stage to capture cross-channel interaction information and improve the feature extraction capability of the network;
[0021] S32, Construct a segmented subnetwork based on a U-net-like structure;
[0022] S33 connects the two sub-networks to obtain the surface defect detection model.
[0023] The method for constructing a product surface defect detection model based on an autoencoder includes the following formula for the hybrid loss function:
[0024] L(I,I) r M a M) = L rec (I, I) r )+L seg (M a M)
[0025] Where I is the input image, I r To reconstruct the image, M is the output segmented image. a For the truth label image; L(I, I r M a M) is the total loss function, L rec For the loss function in the reconstruction phase, L seg The loss function for the segmentation stage;
[0026] L rec (I, I) r )=λL SSIM (I, I) r )+L2(I,I r )
[0027] Where L SSIM The SSIM loss is used to measure the similarity between two images, L2 is the mean squared error, and λ is the balancing hyperparameter between the two losses, which is set to 1.
[0028]
[0029] Where H and W are the height and width of the original image I, respectively, and N... p I represents the number of pixels in the original image. r It is the reconstructed image output by the network, SSIM(I, I) r ) (i,j) for I and I r The SSIM value centered at image coordinates (i, j);
[0030] L seg (p t )=-α t (1-p t ) γ log(p t )
[0031] Where p t It reflects the difficulty of classification, through the modulation factor (1-p). t ) γ Increase the weight of hard-to-distinguish samples, setting γ to 2, and also α t It can adjust the ratio between positive and negative sample losses to suppress the imbalance in the number of positive and negative samples.
[0032] The method for constructing a product surface defect detection model based on autoencoder reconstruction includes a product surface defect detection device based on autoencoder reconstruction, the device comprising the following modules:
[0033] The data acquisition module is used to collect and organize various industrial product datasets, including defect-free normal samples and defective abnormal samples.
[0034] The enhancement module adds noise to the foreground of normal samples, randomly using three data augmentation methods during the noise addition process.
[0035] The training module is used to train the surface defect detection model. After data augmentation, the image is input into the reconstruction subnetwork and the segmentation subnetwork for model training.
[0036] The detection module is used for defect identification and location. The sample to be tested is input into the surface defect detection model for model testing.
[0037] The method for constructing a product surface defect detection model based on autoencoder reconstruction includes a product surface defect detection device based on autoencoder reconstruction. The electronic equipment of the device includes a processor, a memory, and a computer program stored in the memory and running on the processor.
[0038] The method for constructing a product surface defect detection model based on autoencoder reconstruction includes a product surface defect detection device based on autoencoder reconstruction, wherein the device is equipped with a computer-readable storage medium, and the computer-readable storage medium stores a computer program that can be executed by a processor.
[0039] The present invention has the following beneficial effects:
[0040] (1) This method only requires normal samples without defects during training and does not require any manually labeled defective or abnormal samples, which greatly reduces the workload of data preprocessing.
[0041] (2) Considering the influence of background interference in the product dataset, an effective anomaly generation module including a foreground enhancement strategy was designed and introduced during training to simulate the generation of various defects in order to solve the problem of scarce real defect samples.
[0042] (3) The proposed model is an end-to-end surface defect detection model. The input image can directly output an accurate anomaly localization segmentation map, avoiding additional manual preprocessing and postprocessing, increasing the overall fit of the model, improving the detection speed, and achieving the maximum detection capability. Attached Figure Description
[0043] The accompanying drawings, as part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments and descriptions of the invention are used to explain the invention, but do not constitute an undue limitation of the invention. Obviously, the drawings described below are merely some embodiments, and those skilled in the art can obtain other drawings based on these drawings without creative effort. In the drawings:
[0044] Figure 1 A schematic diagram of a method for constructing a surface defect detection model based on autoencoder reconstruction according to an embodiment of the present invention;
[0045] Figure 2 : Overall flowchart of the method architecture of this invention;
[0046] Figure 3 : Flowchart of the simulation exception generation module of this invention;
[0047] Figure 4 This invention reconstructs the sub-network architecture diagram;
[0048] Figure 5 : Diagram of the segmented sub-network architecture of this invention;
[0049] Figure 6 : A visualization of the surface defect detection results of this invention;
[0050] Figure 7 : Schematic diagram of the surface defect detection device of the present invention. Detailed Implementation
[0051] The specific embodiments of the present invention will now be described in further detail with reference to the accompanying drawings.
[0052] Figure 1 A schematic diagram of the process for constructing a surface defect detection model based on autoencoder reconstruction according to the present invention is shown. Figure 1 As shown, the method for constructing this detection model includes:
[0053] S1 involves collecting and organizing various industrial product datasets. Table 1 provides relevant information about these datasets.
[0054] Table 1. Dataset Description
[0055]
[0056] S2, Design an anomaly generation module: This module simulates and generates defective anomalous samples from normal, undefective samples within the dataset. Specifically, Figure 3 The flowchart of the exception generation module is shown. S2 includes the following steps:
[0057] S21, the noisy image P is generated by a Berlin noise generator to capture various anomalous shapes, and binarized using a threshold T (T = 0.5) with random uniform sampling to form an anomalous mask image P. m ;
[0058] S22, using the Otsu method to distinguish the foreground and background of industrial products by maximizing the inter-class variance, the input image I is binarized and segmented to obtain the mask I. m Next, two masks P are used. m and I m Element-wise multiplication yields the mask image M;
[0059] M = P m ⊙I m
[0060] S23, the abnormal texture source image D is sampled from an abnormal source dataset whose distribution is independent of the input image I. To maintain the diversity of abnormal generation, three types of samples are randomly selected from the set {tone separation, sharpness, exposure enhancement, equalization, brightness variation, color variation, automatic contrast} for enhancement sampling of the abnormal source image D. The enhanced texture image D and the input image I are masked by a mask M and compared with the input image I. The masked input image I is blended to obtain the final simulated anomaly generated image I. A .
[0061]
[0062] Where β is the opacity parameter during blending, following a random uniform distribution in the range [0.1, 1.0], and ⊙ represents the successive multiplication operation. It is P m The reverse of the original.
[0063] In addition to performing various data augmentations on the abnormal texture source image D, this strategy also randomly rotated 30% of the input image I and the Berlin noise P within a range of [-90°, 90°] to enhance the model's learning ability. Furthermore, considering the diversity of defects in various components under real-world industrial conditions, by randomly changing the size of the Berlin noise during anomaly generation, the granularity of the noise image can be controlled to obtain anomaly mask images P of various sizes and shapes. m .
[0064] S3 constructs a surface defect detection model using an autoencoder-based reconstruction subnetwork and a U-net-like segmentation subnetwork. S3 includes the following steps:
[0065] S31, a reconstruction sub-network based on an autoencoder is constructed, in which an efficient channel attention (ECA) module is added in the encoding stage to capture cross-channel interaction information and improve the network's feature extraction capability. Figure 4 The diagram shows the reconstructed subnetwork architecture.
[0066] Specifically, the reconstructed subnetwork is an encoder-decoder structure, which can convert the input image I... A The local abnormal patterns are reconstructed into patterns that more closely resemble the normal sample distribution, while preserving the non-abnormal regions of the input image, resulting in a reconstructed image I of the same size as the input image. r .
[0067] The ECA attention mechanism module compresses the spatial features of the input feature map (H×W×C) using global average pooling (GAP) to obtain a 1×1×C feature map. Channel feature learning is then performed on the compressed feature map, using 1×1 convolutions to learn the importance between different channels, resulting in a 1×1×C feature map with channel attention information. During convolution operations, the size of the convolution kernel affects the receptive field. To address the issue of extracting different ranges of features from input feature maps with varying numbers of channels, ECA uses dynamic convolution kernels. Larger kernels are used in layers with a higher number of channels, while smaller kernels are used in layers with a lower number of channels. This allows for local cross-channel interaction information between each channel and its k neighbors, with the kernel size adaptively varying via a function.
[0068]
[0069] Where k represents the kernel size, represents the coverage of local cross-channel interactions, i.e., how many neighbors of this channel participated in the attention prediction of this channel, and C represents the number of channels. odd This indicates that k can only be an odd number, γ = 2, and b = 1 are used to change the ratio between the number of channels C and the kernel size.
[0070] Finally, the channel attention feature map (1×1×C) is multiplied channel by channel with the original input feature map (H×W×C) to output a feature map with efficient channel attention.
[0071] S32, construct a segmentation sub-network based on a U-net-like architecture, where, Figure 5 The diagram shows the architecture of the segmented subnetwork.
[0072] Specifically, the segmentation subnetwork uses a U-net-like structure, first reconstructing the subnetwork's input I...A and output I r After concatenating the channels, the data is input into the segmentation sub-network. This provides sufficient information for segmenting anomalies. Next, after downsampling through five convolutional blocks, multi-scale feature extraction is performed. This part includes the original... Figure 1 There are 6 scales to fully extract features. In the upsampling part, the feature map of the corresponding size of the feature extraction part is copied and merged every time it is upsampled, and finally restored to the original image size to obtain an accurate defect segmentation map.
[0073] S33 connects the two sub-networks to obtain the surface defect detection model, where... Figure 2 The overall flowchart of the methodology architecture is shown.
[0074] Specifically, the proposed method architecture consists of a reconstruction subnetwork and a segmentation subnetwork. The reconstruction subnetwork uses an encoder-decoder structure with an efficient attention mechanism to restore and reconstruct the input anomaly image to obtain a reconstructed map. Subsequently, the input and output of the reconstruction subnetwork are concatenated and fed into a U-net-like segmentation subnetwork to generate an anomaly segmentation map. During the testing phase, the sample to be tested can be directly input into the network architecture, and an accurate defect detection segmentation map can be obtained through rapid computation.
[0075] S4, the simulated defect samples are used to train the defect detection model, and the model's loss function adopts a hybrid loss function.
[0076] SSIM has become a common loss function in computer vision, typically used to measure the similarity between two images. SSIM primarily considers three key image features: brightness, contrast, and structure.
[0077] The definition of SSIM is:
[0078] S(x, y) = l(x, y) α ×c(x, y) β ×s(x, y) γ
[0079] Where l represents luminance similarity, c represents contrast similarity, s represents structural similarity, and a, β, and γ are balance hyperparameters.
[0080] Brightness is measured by average grayscale, which is obtained by averaging the values of all pixels. If an image has N pixels, the pixel value of each pixel is x. i Therefore, the average brightness of the image is:
[0081]
[0082] Then the brightness similarity between the two images:
[0083]
[0084] Contrast is the degree of drastic change in the brightness of an image, which is expressed in terms of pixel value x. i The standard deviation is measured by the grayscale standard deviation. Unbiased estimate of standard deviation:
[0085]
[0086] Then the contrast similarity between the two images:
[0087]
[0088] When studying structural similarity, the influence of brightness and contrast should be excluded. Ultimately, the study focuses on normalizing two vectors: (x-μ) x ) / σ x and (y-μ) y ) / σ y
[0089] The structural similarity between the two images is as follows:
[0090]
[0091] In the above, C1, C2, and C3 are constants. To avoid the denominator being zero, we set them as follows: a = β = γ = 1, which ultimately simplifies SSIM to:
[0092]
[0093] In the reconstruction subnetwork, L2 loss is commonly used in reconstruction-based anomaly detection methods, but this assumes that adjacent pixels are independent. Therefore, SSIM loss is used additionally to enhance the interaction between pixels.
[0094]
[0095] Where H and w are the height and width of the original image I, respectively, and N... p I represents the number of pixels in the original image. r It is the reconstructed image output by the network, SSIM(I, I) r ) (i,j) for I and I r The SSIM value centered at image coordinates (i, j) is used, therefore the reconstruction loss is:
[0096] L rec (I, I) r )=λL SSIM (I, I) r )+L2(I,I r )
[0097] Where λ is the balancing hyperparameter between the two losses, set to 1.
[0098] The focus loss function is used to... seg Applying this to the output of the segmentation subnetwork can improve the robustness of accurate segmentation of difficult samples, while also solving the problem of imbalance between positive and negative samples.
[0099] L seg (p t )=-α t (1-p t ) γ log(p t )
[0100] Where p t This reflects the difficulty of classification, p t A larger value indicates higher confidence in the classification, meaning the sample is easier to classify; p t A smaller value indicates lower classification confidence, meaning the samples are more difficult to classify. This is determined by the modulation factor (1-p). t ) γ Setting γ=2 increases the weight of difficult-to-classify samples in the loss function, making the loss function biased towards difficult samples, which helps improve the accuracy of difficult-to-classify samples. Additionally, α... t It can adjust the ratio between positive and negative sample losses to suppress the imbalance in the number of positive and negative samples.
[0101] Considering the reconstruction and segmentation objectives of the two sub-networks, the total loss during training is:
[0102] L(I,I) r M a M) = L rec (I, I) r )+L seg (M a M)
[0103] Where I is the input image, I r To reconstruct the image, M is the output segmented image. a The image is the truth label image. L(I, I) r M a M) is the total loss function, L rec For the loss function in the reconstruction phase, L seg This is the loss function for the segmentation stage.
[0104] The optimizer used during the training phase was Adam, with a training iteration cycle of 700. The initial learning rate was 0.0001, and the learning rate was decayed at the 560th and 630th iteration cycles with a decay coefficient of 0.2. The batch size of the input images was 16, and the image size was uniformly scaled to 256×256.
[0105] To quantitatively evaluate detection performance, we calculated several evaluation metrics. The primary metric used for comparison is the Area Under the Receiver Operating Characteristic (AUROC), a standard measure in anomaly detection. Mathematically, the Receiver Operating Characteristic measure is a graph that comprehensively reflects both the False Positive Rate (FPR) and the True Positive Rate (TPR). Image-level AUROC values always fall between 0 and 1; values closer to 1 indicate better anomaly detection. Pixel-level AUROC can also be used to evaluate anomaly pixel localization. However, in reality, most anomaly regions are relatively small. Therefore, in the detection of only a small subset of pixels with anomalies, the metric value is dominated by a very high number of non-anomaly pixels, making pixel-level AUROC insufficient to accurately reflect localization accuracy. Therefore, we additionally calculated the Mean Precision (AP), the area under the curve of precision versus recall. This is more suitable for highly imbalanced categories, particularly surface anomaly detection, where precision plays a crucial role.
[0106] The proposed method is compared with recent unsupervised anomaly detection methods for images, including GANomaly, CutPaste, DRAEM, STAD, and Padim. The image-level and pixel-level anomaly detection results for the five datasets are shown in Tables 2 and 3. Overall, the proposed method outperforms other methods in many categories, achieving the best image-level average AUROC, pixel-level average AUROC, and AP metrics. Table 2 shows that the proposed method performs well not only on the screw dataset with extremely small and indistinguishable anomaly regions but also on the toothbrush dataset with limited training samples, demonstrating its effectiveness. Table 3 shows that the proposed method improves the pixel-level average AUROC by 0.6% compared to Padim and the pixel-level average AP by 12.5% compared to DRAEM. This is attributed to the efficient channel attention, which enhances the model's ability to reconstruct images with missing irregular artifacts, while the foreground enhancement strategy eliminates background interference, allowing the model to acquire more effective information during learning.
[0107] Table 2 Comparison of Image-Level AUROC% Performance
[0108]
[0109]
[0110] Table 3. Pixel-level AUROC / AP% performance comparison
[0111]
[0112] Figure 6 The proposed method is visualized for surface defect detection results on five datasets. Each dataset includes, from top to bottom, the original test input image, the defect ground truth label image, the reconstructed image, and the anomaly segmentation output image. It can be seen that the proposed method can clearly reconstruct and restore the anomaly image while accurately locating surface defects on the product.
[0113] The present invention also provides a specific embodiment of a surface defect detection device based on autoencoder reconstruction, comprising:
[0114] The data acquisition module is used to collect and organize various industrial product datasets, including normal samples without defects and abnormal samples with defects, and classifies the types of defects.
[0115] The anomaly generation module is used for adding noise to the foreground of normal samples. When adding noise, it randomly selects three types from the set {tone separation, sharpness, exposure, equalization, brightness change, color change, automatic contrast} for data augmentation.
[0116] The training module is used to train the surface defect detection model. After data augmentation, the image is input into the reconstruction subnetwork and the segmentation subnetwork for model training.
[0117] The detection module is used for defect identification and location. It inputs the sample to be tested into the surface defect detection model for model testing.
[0118] The present invention also provides a surface defect detection electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the method embodiment described above in Embodiment 1 of the present invention.
[0119] Furthermore, as an executable solution, the surface defect detection electronic device can be a computing device such as a desktop computer, laptop, handheld computer, or cloud server. The surface defect detection electronic device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the above-described composition of the surface defect detection electronic device is merely an example and does not constitute a limitation on the surface defect detection electronic device. It may include more or fewer components than described above, or combine certain components, or different components. For example, the surface defect detection electronic device may also include input / output devices, network access devices, buses, etc., and this embodiment of the invention does not limit this.
[0120] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the method described in the embodiments of the present invention.
[0121] Furthermore, if the modules or units integrated in the surface defect detection electronic device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), and a software distribution medium, etc.
[0122] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-described technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A method for constructing a product surface defect detection model based on an auto-encoder reconstruction, characterized in that, The method comprises the following steps: S1, collecting and sorting various industrial product data sets; S2, designing an anomaly generation module capable of simulating the generation of defect samples; S3, constructing a surface defect detection model using a reconstruction subnetwork based on an autoencoder and a segmentation subnetwork based on a U-net-like structure; S4, using the simulated defect samples to train the defect detection model, and using a hybrid loss function as the loss function of the model; S5, inputting the to-be-tested sample into the defect detection model, reconstructing the defect image, and comparing it with the original sample to obtain an abnormal positioning segmentation result; The step S2 comprises the following steps: S21, Noisy Image P Generated by a Berlin noise generator to capture various anomalous shapes, using a threshold obtained through random uniform sampling. T , T=0.5 Binarization is performed to generate an anomaly mask image. P m ; S22, using Otsu method to distinguish foreground and background of industrial product according to inter-class variance maximization, thereby carrying out binary segmentation on the input image to obtain a mask I m m , next using two masks P m and I m element-wise product to obtain a mask image M ; ; S23, abnormal texture source image D from the input image I distribution-independent abnormal source dataset sampling, while keeping the diversity of the generated abnormalities, the abnormal source image D Extract three kinds of random enhancement sampling from the set {hue separation, sharpness, exposure, equalization, brightness change, color change, automatic contrast}; the enhanced texture image D and the input image I Masked M Covered, and mixed with the input image masked I to get the final simulated abnormality generation image I A ; ; wherein is the opacity parameter at the time of mixing, subject to a [0.1, 1.0] random uniform distribution, is a per-element multiplication operation, is P m is the bitwise NOT of The step S3 comprises the following steps: S31, constructing a reconstruction subnetwork based on an autoencoder, and adding an efficient channel attention module in the encoding stage to capture cross-channel interaction information and improve the feature extraction capability of the network; S32, constructing a segmentation subnetwork based on a U-net-like structure; S33, connecting the two subnetworks to obtain a surface defect detection model; The hybrid loss function formula is as follows: ; wherein I is an input image, I r is an input image is a reconstructed image, M is an output segmentation image, M a is a ground truth label image; L I, I r ,M a ,M is a total loss function, L rec is a reconstruction stage loss function, L seg is a segmentation stage loss function; ; wherein L SSIM is the SSIM loss for measuring the similarity between two images, L 2 is the mean squared error, is a balancing hyperparameter for the two losses, set to 1; ; in H and W Original image I Height and width, N p This represents the number of pixels in the original image. I r It is the reconstructed image output by the network. SSIM ( I, I r ) (i,j) for I and I r Image coordinates ( i, j The SSIM value centered on ) ; wherein p t reflects the difficulty of classification, and the modulation factor increases the weight of difficult-to-classify samples, is set to 2, and otherwise can adjust the ratio between positive and negative sample losses, and inhibit the number imbalance of positive and negative samples; The method comprises a product surface defect detection device based on an autoencoder reconstruction, and the module composition of the device comprises: The acquisition module is used to collect and sort various industrial product data sets, including normal samples without defects and abnormal samples with defects; The enhancement module is used for noise processing of the normal sample foreground, and three data enhancement methods are randomly used during noise processing; The training module is used for training of the surface defect detection model, and the image after data enhancement is input into the reconstruction subnetwork and the segmentation subnetwork for model training; The detection module is used for defect recognition and positioning, and the to-be-tested sample is input into the surface defect detection model for model testing.
2. The method of claim 1, wherein the method comprises: The method comprises a product surface defect detection device based on an autoencoder reconstruction, and the electronic equipment composition of the device comprises a processor, a memory, and a computer program stored in the memory and running on the processor.
3. The method of claim 2, wherein the method further comprises: The method comprises a product surface defect detection device based on an autoencoder reconstruction, and the electronic equipment computer readable storage medium of the device stores a computer program executed by the processor.
Citation Information
Patent Citations
Product surface defect detection method, device and equipment and storage medium
CN114170227A