Workpiece defect detection method based on reverse distillation and auxiliary segmentation
The method enhances unsupervised workpiece defect detection by using reverse distillation and auxiliary segmentation with synthesized pseudo-defect images and a difference-guided synchronization module to improve sensitivity and accuracy in complex backgrounds.
Patent Information
- Application Number
- CN202411257360.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2044-09-09
AI Technical Summary
Existing unsupervised workpiece defect detection methods struggle with complex background noise and the difficulty in obtaining large-scale labeled defect images, leading to insensitivity and inaccurate defect detection and localization.
A workpiece defect detection method based on reverse distillation and auxiliary segmentation, using pseudo-defect images synthesized through fractal anomaly generation, combined with a pre-trained teacher encoder and a difference-guided synchronization module, to enhance sensitivity to defects and reduce background noise interference.
Achieves accurate and stable defect detection and positioning in complex backgrounds, improving performance by focusing on key features and minimizing background noise interference.
Smart Images

Figure CN118762030B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of workpiece defect detection, and in particular relates to a workpiece defect detection method based on reverse distillation and auxiliary segmentation. Background Art
[0002] The production of industrial parts is a very important part of modern industrial production, directly or indirectly affecting the development of all walks of life. Therefore, it is crucial to detect defects in industrial products in industrial scenarios. Industrial defect detection refers to the technology of identifying and locating defect areas during industrial manufacturing or maintenance. Among them, the range of defects ranges from subtle changes (such as scratches) to larger structural defects (such as missing parts). In recent years, with the development of computer technology, workpiece defect detection methods based on deep learning have gradually replaced traditional manual visual inspection. Among them, methods based on supervised learning rely on large-scale accurately labeled normal images and defect images to train models to detect and locate defects. However, due to the strict yield control in the industrial production process, it is very difficult to obtain large-scale accurately labeled defect images. In addition, it is also very cumbersome to accurately label defect images. Therefore, most of the current research focuses on defect detection based on unsupervised learning, which can be divided into two subcategories: defect detection methods without knowledge distillation and defect detection methods based on knowledge distillation.
[0003] Among them, the non-knowledge distillation methods are divided into two categories: reconstruction-based and memory-based. Early reconstruction-based methods identify and locate defects by calculating the reconstruction error between the input image and the reconstructed image. However, due to the lack of real defect sample supervision, it is difficult for the model to find a clear generalization boundary. Therefore, the memory-based method uses a pre-trained feature extractor to construct a reasonable normal feature distribution and identify defects through feature matching, but this requires additional storage and matching calculations. The knowledge distillation-based method trains the student network on the normal image to imitate the pre-trained teacher network, so that the student and teacher get consistent representations in the normal area. In the test phase, the student network and the teacher network will show differences in the defect area, and the defects are detected by comparing the differences between the two. Due to the simplicity and effectiveness of the knowledge distillation method, recent studies tend to explore such methods. For example, Cao et al. introduced collaborative difference optimization into the teacher-student structure for reliable defect location. However, due to the isomorphism and the same data flow of the traditional teacher-student structure, the student network may also produce a consistent representation with the teacher network in the defect area, resulting in insensitivity to defects. In addition, most of the existing unsupervised defect detection methods are designed or evaluated based on datasets such as MVTec AD, VisA, and MVTecLOCO AD. These datasets have some common characteristics, such as aligned samples in each category and pure background, and rarely consider the impact of complex background noise in workpiece images on defect detection. Summary of the invention
[0004] The purpose of the present invention is to provide a workpiece defect detection method based on reverse distillation and auxiliary segmentation to address the problems of complex background of workpiece images and difficulty in obtaining defect samples. The method can achieve excellent workpiece defect detection and positioning performance under complex backgrounds.
[0005] To achieve the above object, the technical solution of the present invention is: a workpiece defect detection method based on reverse distillation and auxiliary segmentation, comprising:
[0006] The normal image is used to produce a pseudo defect image and a corresponding mask image by using a fractal anomaly generation method;
[0007] Sending normal images and pseudo-defect images to a workpiece defect detection model for training, thereby obtaining a workpiece defect detection model that can distinguish normal images from defect images and locate defect positions in defect images;
[0008] Based on the trained workpiece defect detection model, workpiece defect detection and defect location of the input image to be detected are realized.
[0009] In one embodiment of the present invention, the workpiece defect detection model includes a pre-trained teacher encoder with frozen weights, a multi-scale feature fusion module, a student decoder, a difference-guided synchronization module, and an end-to-end semantic segmentation network.
[0010] In one embodiment of the present invention, the training process of the workpiece defect detection model is as follows:
[0011] (1) Reverse distillation:
[0012] For the normal input image X nor , Pseudo defect image X defect ,The multi-scale teacher features are obtained by extracting features through the pre-trained teacher encoder with frozen weights;
[0013] The multi-scale teacher features are input into the multi-scale feature fusion module for multi-scale feature fusion to obtain multi-scale fusion features, and the high-dimensional features are projected into the low-dimensional feature space through the residual module to obtain compact low-dimensional embedded features. Then, the multi-scale student features are obtained by using the reverse structure of the pre-trained teacher encoder with frozen weights as the student decoder;
[0014] For teacher features and student features, the cosine similarity along the channel dimension is calculated as the reverse distillation loss ; When the input image is a normal image, the student decoder is in the reverse distillation loss To reconstruct the normal image features under the guidance of , so as to imitate the feature extraction ability of the pre-trained teacher encoder with frozen weights for normal images during the training process;
[0015] (2) Auxiliary segmentation:
[0016] Using pseudo defect images X defect and the corresponding mask image Mask By designing a difference-guided synchronization module to apply adaptive difference weights and cosine difference attention on student features, we obtain the weighted attention features of student features; we introduce an end-to-end semantic segmentation network to perform defect segmentation on the weighted attention features of student features, obtain the segmentation prediction image, and calculate the segmentation prediction loss of the mask image and the segmentation prediction image corresponding to the pseudo defect image , and then update the workpiece defect detection model parameters through back propagation to obtain a workpiece defect detection model that can distinguish normal images from defective images and locate the defect position in the defective image.
[0017] In one embodiment of the present invention, the pre-trained teacher encoder with frozen weights uses the outputs of the first three layers of WideResNet50 pre-trained on the ImageNet dataset as the outputs of the pre-trained teacher encoder with frozen weights.
[0018] In one embodiment of the present invention, the reverse distillation is specifically implemented as follows:
[0019] For the normal input image X nor , the multi-scale teacher features are obtained by feature extraction through the pre-trained teacher encoder with frozen weights, which is defined as follows:
[0020]
[0021] in, E k Indicates k Pre-trained teacher encoder with frozen layer weights, k∈(1,2,3) ;
[0022] The multi-scale teacher features are input into the multi-scale feature fusion module for multi-scale feature fusion to obtain multi-scale fusion features, and the high-dimensional features are projected into the low-dimensional feature space through the residual module to obtain compact low-dimensional embedded features. Then, the multi-scale student features are obtained by using the reverse structure of the pre-trained teacher encoder with frozen weights as the student decoder. The whole process is defined as follows:
[0023]
[0024] in, D kIndicates k layer student decoder, out Represents the output of the multi-scale feature fusion module, BN represents batch normalization operation, and Relu is an activation function;
[0025] Characteristics of teachers and student characteristics , and calculate its cosine similarity along the channel dimension as the reverse distillation loss , defined as follows:
[0026]
[0027] in, M k Indicates k Characteristics of teachers at the first level and k The cosine similarity of the student features of the layer, M k It is expressed as follows:
[0028]
[0029] in, h k 、w k Respectively represent k The height and width of the teacher feature / student feature of the layer, T is the transposed sign;
[0030] When the input image is a normal image, the student decoder performs well in the back distillation loss. To reconstruct the normal image features under the guidance of , so as to imitate the feature extraction ability of the pre-trained teacher encoder with frozen weights for normal images during the training process;
[0031] For pseudo defect images X defect Execution and normal image X nor The same operation is performed to obtain the teacher characteristics and student characteristics .
[0032] In one embodiment of the present invention, the auxiliary segmentation is specifically implemented as follows:
[0033] (2.1) Design a difference-guided synchronization module to amplify the teacher features of pseudo-defect images and student characteristics The difference between them makes the workpiece defect detection model focus on the key features among the teacher-student features; specifically as follows:
[0034] First, we introduce cosine difference attention to calculate the key difference between teacher and student features. The cosine difference attention is defined as follows:
[0035]
[0036] in, Cosatt k Indicates k cosine difference attention of layer teacher-student features;
[0037] Secondly, an adaptive difference weight module is designed between the teacher network and the student network to assign a difference weight to each channel of the absolute difference between the teacher and student features. The difference weight is defined as follows:
[0038]
[0039] Among them, ADWM is the adaptive difference weight module. abs(·) represents the calculation of the absolute difference between teacher and student characteristics, Weight k Indicates k Adaptive differential weights of teacher-student characteristics at each level;
[0040] Finally, by Apply adaptive difference weight and cosine difference attention to get the weighted attention feature of student feature:
[0041]
[0042] in, Indicates k The weighted attention features of the student features at the layer, k∈(1,2,3) ;
[0043] (2.2) Introduce an end-to-end semantic segmentation network to perform defect segmentation on the weighted attention features of the student features, obtain the segmentation prediction image, and calculate the segmentation prediction loss of the mask image and the segmentation prediction image corresponding to the pseudo defect image :
[0044]
[0045] in, , They are Dice loss and binary cross entropy loss, Pre=SF(f s ) is the segmentation prediction image output by the end-to-end semantic segmentation network, SF represents the end-to-end semantic segmentation network, f s is a list of three weighted attention features of different sizes;
[0046] Based on segmentation prediction loss , the workpiece defect detection model parameters are updated by back propagation, and a workpiece defect detection model is obtained which can distinguish normal images from defective images and locate the defect position in the defective image.
[0047] Compared with the prior art, the present invention has the following beneficial effects: the method of the present invention proposes an unsupervised defect detection method based on reverse distillation and auxiliary segmentation. First, artificially synthesized defect images are used to enhance the sensitivity of the student network to defects through reverse distillation; secondly, a difference-guided synchronization module is designed to reduce background noise interference; finally, an end-to-end semantic segmentation network is used for auxiliary segmentation, and the model parameters are optimized by minimizing the segmentation prediction loss, so that the model can learn the key features of the image in a targeted manner to ignore background noise. The method of the present invention can achieve accurate and stable workpiece defect detection and positioning in complex backgrounds. The method of the present invention can overcome the shortcomings in the field of unsupervised workpiece defect detection to a certain extent and has improved performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 This is the RDSeg model framework proposed by the method of the present invention.
[0049] Figure 2 This is the structure diagram of the multi-scale feature fusion module.
[0050] Figure 3 This is the structure diagram of the difference guidance synchronization module DGSM.
[0051] Figure 4 This is the testing phase of the workpiece defect detection framework RDSeg.
[0052] Figure 5 These are some image examples from the MPDD dataset.
[0053] Figure 6 Qualitative results of different methods on defect images.
[0054] Figure 7 Qualitative results of different methods on normal images. DETAILED DESCRIPTION
[0055] The technical solution of the present invention is described in detail below in conjunction with the accompanying drawings.
[0056] The present invention proposes a workpiece defect detection method based on reverse distillation and auxiliary segmentation, comprising:
[0057] The normal image is used to produce a pseudo defect image and a corresponding mask image by using a fractal anomaly generation method;
[0058] Sending normal images and pseudo-defect images to a workpiece defect detection model for training, thereby obtaining a workpiece defect detection model that can distinguish normal images from defect images and locate defect positions in defect images;
[0059] Based on the trained workpiece defect detection model, workpiece defect detection and defect location of the input image to be detected are realized.
[0060] The following is the specific implementation process of the present invention.
[0061] The method of the present invention proposes an unsupervised workpiece defect detection model RDSeg based on reverse distillation model and auxiliary segmentation. First, artificially synthesized defect images are used to enhance the sensitivity of the student network to defects through reverse distillation; secondly, a difference-guided synchronization module is designed to reduce background noise interference; finally, an end-to-end semantic segmentation network is used for auxiliary segmentation, and the model parameters are optimized by minimizing the segmentation prediction loss, so that it can learn the key features of the image in a targeted manner to ignore background noise. Figure 1 As shown, the workpiece defect detection model RDSeg of the present invention includes the following five modules: a pre-trained teacher encoder with frozen weights, a multi-scale feature fusion module, a student decoder, a Difference Guide Synchronization Module (DGSM), and a SFNet for auxiliary segmentation.
[0062] For the workpiece defect detection task, first a set of normal training samples is given X nor :x 1 ,x 2 …,x n , and then use the Fractal Anomaly Generation (FAG) method to create a pseudo-defect image X defect :x 1 ', x 2 '…,x n ' and the corresponding mask image Mask:m 1 ,m 2 …,m n Then X nor and X defectThe images are sent to the model in parallel for training. The goal of model training is to build a detection model that can distinguish between normal images and defective images and locate defects in defective images. The training phase mainly includes two steps: reverse distillation and auxiliary segmentation. In the test phase, the segmentation prediction image generated by the segmentation network is used to perform defect detection and defect location.
[0063] 1. Reverse distillation
[0064] Unsupervised defect detection based on knowledge distillation is based on the following assumption: that the student network can learn the domain prior knowledge contained in normal images from the pre-trained teacher network through knowledge distillation. Since the student network is only trained on normal images, it will produce feature representations inconsistent with the teacher network when processing defect images. However, Deng et al. pointed out that due to the structural similarity of the teacher-student network and the same data flow of the teacher-student network during the knowledge distillation process, this difference in defect representation may disappear, resulting in the failure of this assumption. Therefore, the present invention introduces a reverse distillation structure to process artificially synthesized pseudo-defect images and original normal images to assist the student network in learning more accurate decision boundaries, thereby improving the model's sensitivity to defects.
[0065] Specifically, normal images and pseudo-defect images synthesized using the fractal anomaly generation method FAG are input into the teacher-student network in parallel for training. First, the outputs of the first three layers of WideResNet50 pre-trained on ImageNet are used as the output of the teacher encoder E to extract the multi-scale feature representation of the input image. In order to avoid the teacher-student network from converging to a trivial solution, all parameters of the teacher encoder E are frozen during the knowledge distillation process. Then, the features extracted by the teacher encoder E are fed into the multi-scale feature fusion module for multi-scale feature fusion, and then the high-dimensional features are projected into a low-dimensional feature space through the residual module to obtain compact low-dimensional embedded features. This helps to prevent background noise from propagating to the student network and reduce the impact of background noise on the student network. Finally, the reverse structure of the teacher encoder is used as the student decoder D to accept the multi-scale fusion features output from the multi-scale feature fusion module. The multi-scale feature fusion module is as follows Figure 2 As shown, it receives three inputs I 1 、I 2 、I 3 Teacher Coder E 1 、E 2 、E 3 Output teacher characteristics.
[0066] When the input image is a normal image, the student decoder D Losses in reverse distillation The goal is to imitate the teacher encoder E’s ability to extract normal image features during the training process.
[0067] First, for the normal input image X nor , the multi-scale teacher features are obtained by feature extraction through the teacher encoder, which is defined as follows:
[0068]
[0069] in, E k Indicates k Layer Teacher Coder, k∈(1,2,3) .
[0070] Secondly, the multi-scale teacher features obtained in the previous step are input into the multi-scale feature fusion module for feature fusion to improve the model's sensitivity to defects of different scales. The multi-scale fusion features are then input into the residual module to obtain compact low-dimensional features to reduce the impact of noise features on the student decoder, which is defined as follows:
[0071]
[0072] in, D k Indicates k layer student decoder, out Represents the output of the multi-scale feature fusion module, BN represents the batch normalization operation, and Relu is an activation function.
[0073] Finally, for teacher characteristics and student characteristics , and calculate its cosine similarity along the channel dimension as the reverse distillation loss , defined as follows:
[0074]
[0075] in, M k Indicates k Characteristics of teachers at the first level and k The cosine similarity of the student features at each layer.
[0076]
[0077] in, h k 、w k Respectively represent kThe height and width of the teacher / student features of the layer, T is the transposed sign.
[0078] For pseudo defect images X defect Execution and normal image X nor The same operation is performed to obtain the teacher characteristics and student characteristics .
[0079] 2. Auxiliary segmentation
[0080] In order to reduce the impact of complex background on workpiece defect detection and obtain more accurate defect detection and positioning performance, the present invention adds an auxiliary segmentation stage after reverse distillation. First, the artificially synthesized pseudo defect image is used X defect : x 1 ',x 2 '…,x n ' and the corresponding mask image Mask:m 1 ,m 2 …,m n , through the designed difference-guided synchronization module DGSM, adaptive difference weights and cosine difference attention are applied to the student features, so that the student network focuses on key features and reduces the interference of complex background. Then, an end-to-end semantic segmentation network SFNet is introduced to perform defect segmentation on the student features and calculate the segmentation prediction loss of the pseudo defect mask image and the segmentation prediction image , and then update the model parameters through back propagation. This step will provide an effective learning and optimization path for the model, assisting the model to focus on the main body of the image and ignore background information irrelevant to the task, further enhancing the model's sensitivity and identification ability to defects and alleviating complex background interference.
[0081] 2.1. Difference-guided synchronization module
[0082] First, in order to amplify the teacher features of the pseudo-defect image and student characteristics The difference between the two makes the model focus on the key features among the teacher-student features, improves the sensitivity of the model to defects and reduces the impact of background noise. The present invention designs a difference guidance synchronization module DGSM, such as Figure 3 shown.
[0083] First, cosine difference attention is introduced to calculate the key difference between teacher and student features. Since cosine difference focuses on the consistency of feature vector direction and is insensitive to absolute values, it is insensitive to image scale and brightness changes, and can resist the interference of noise and small disturbances in the image to a certain extent. Therefore, while capturing key difference features, it can help the model ignore irrelevant background noise to a certain extent, thereby improving the accuracy and reliability of defect detection under complex background noise interference. The specific definition is as follows:
[0084]
[0085] in, Cosatt k Indicates k Cosine difference attention of teacher-student features.
[0086] At the same time, the present invention designs an Adaptive Differential Weight Module (ADWM) between the teacher-student network to assign a weight to each channel of the absolute difference between the teacher and student features. Specifically, the larger the difference, the more significant the behavioral difference between the student network and the teacher network on a specific feature channel. Therefore, by learning how to assign weights to the differences, ADWM can guide the student network to focus on features that are particularly important or difficult to learn for imitating the teacher network. Secondly, the channel-level weight adjustment provided by ADWM enables the model to adaptively respond to changes in the data set, such as changes in ambient lighting, changes in background appearance, etc. In addition, for the contextual information of defect detection, the model can focus on features that are more likely to represent defects, thereby reducing the interference of complex backgrounds, and further improving the accuracy of defect detection and positioning under complex background interference. The difference weight is specifically defined as follows:
[0087]
[0088] in, abs(·) It represents the absolute difference between the teacher and student features. Since the absolute difference focuses directly on the numerical difference, it is very sensitive to the slight changes in the image. Combined with the adaptive weights, the model can accurately locate and identify key defects or feature changes in complex backgrounds. Weight k Indicates k Adaptive difference weights of teacher and student characteristics
[0089] Finally, by Applying adaptive difference weights and cosine difference attention can enable the model to learn these areas in a targeted manner and ignore background noise that is not important to the task. This provides an effective learning and optimization path for the model to enhance the model's sensitivity and identification ability to defects and assist the model to pay more attention to defects in the main part of the image. The specific definitions are as follows:
[0090]
[0091] in, Indicates k The weighted attention features of the student features at the layer, k∈(1,2,3) .
[0092] 2.2 Semantic Segmentation Network
[0093] The present invention introduces an end-to-end semantic segmentation network SFNet to receive the weighted attention student features output by the DGSM module to obtain a segmentation prediction image. Optimize the training of the model under the guidance of It is a combination of two common losses, Dice loss and binary cross entropy loss, and is defined as follows:
[0094]
[0095] in, Pre=SF(f s ) is the segmentation prediction image output by the segmentation network, f s is a list of three weighted attention features of different sizes, Mask It is the mask image corresponding to the artificially synthesized pseudo defect image.
[0096] 3. Testing phase
[0097] The test process is as follows Figure 4 As shown, for a given test sample X First, it is input into the teacher-student network, and the teacher features and student features are obtained through reverse distillation. Then it is input into the difference guidance synchronization module DGSM to obtain the weighted attention feature list f s , and finally f s Feed it into the end-to-end semantic segmentation network SFNet to get the segmentation prediction image Pre Defects are located on the test sample. Finally, the segmentation prediction image is used Pre The average value of S Perform defect detection, defined as follows:
[0098]
[0099] in, h*w is the segmentation prediction image Pre The size of i represents the segmentation prediction image Pre A pixel in .
[0100] 4. Experimental data and evaluation
[0101] In order to study the performance of defect detection and defect location of the present invention in workpiece images with background interference, the experiments of the present invention are all carried out on the MPDD dataset.
[0102] The MPDD dataset is a challenging dataset that focuses on detecting defects in the manufacturing process of painted metal parts. The images of the MPDD dataset are captured under different spatial directions, positions and distances, different light intensities and uneven backgrounds, which are closer to real industrial scenes. The dataset includes six categories of painted metal parts. The training set consists of 888 normal sample images, and the test set consists of 176 normal sample images and 282 defect sample images. Pixel-level annotations are provided to evaluate the defect localization results. Some examples of training data on the MPDD dataset are as follows: Figure 5 shown.
[0103] In order to evaluate the effectiveness of the model proposed in this invention, two widely used defect detection and localization indicators are used in this invention: image-level AUROC and pixel-level AUROC. Image-level AUROC is used to evaluate the overall defect detection performance of the model, while pixel-level AUROC is used to evaluate the accuracy of defect localization of the model. AUROC is a value between 0 and 1, and the closer the value is to 1, the better the detection performance. The definition of AUROC is as follows:
[0104]
[0105] Wherein, Area(TPR, FPR) represents the area under the curve calculated with TPR and FPR as the y-axis and x-axis respectively.
[0106]
[0107] Among them, TP represents the number of samples that are actually positive samples and are correctly predicted as positive samples, TN represents the number of samples that are actually negative samples and are correctly predicted as negative samples, FP represents the number of samples that are actually negative samples but are incorrectly predicted as positive samples, and FN represents the number of samples that are actually positive samples but are incorrectly predicted as negative samples.
[0108] In addition, in order to more accurately evaluate the defect location performance, the present invention also calculates the overlap score PRO of each region. Unlike AUROC, the PRO score treats defect regions of any size equally, so the defect location performance can be evaluated more accurately. The formula of PRO is as follows:
[0109]
[0110] Among them, N represents the number of connected regions in the mask label, P represents the predicted value of the model in each connected region, and Gn represents the true value of each connected region.
[0111] 4.1 Qualitative Analysis
[0112] Figure 6 , Figure 7 The figure shows the qualitative analysis results of the RDSeg model proposed in this invention and some state-of-the-art defect detection models on the public metal parts dataset MPDD. Figure 6 , Figure 7 It can be seen from the results that the RDSeg model proposed in the present invention greatly reduces false detection in normal areas, achieves excellent defect localization performance, and has practical application value.
[0113] 4.2 Quantitative Analysis
[0114] Tables 1 to 3 show the quantitative results of the RDSeg model proposed in the present invention and some of the most advanced defect detection models on the public metal parts dataset MPDD. The results show that the performance of the RDSeg model proposed in the present invention is better than other existing state-of-the-art defect detection models and achieves the best results. The model of the present invention achieved 98.46% image-level AUROC, 98.35% pixel-level AUROC and 95.78% overlap curve area under each region (PRO), which are 2.34%, 0.07% and 0.09% higher than the suboptimal model, respectively. It proves that the method of the present invention can achieve excellent defect detection and positioning performance under complex backgrounds.
[0115] Table 1 Defect detection results (AUROC%) of different methods on MPDD dataset
[0116]
[0117] Table 2 Defect localization results (AUROC%) of different methods on MPDD dataset
[0118]
[0119] Table 3 Defect localization (PRO%) results of different methods on the MPDD dataset
[0120]
[0121] 4.3 Ablation study
[0122] The present invention conducts an ablation experiment on the selection of different proposed modules and different backbone networks, further verifying the effectiveness of the method of the present invention.
[0123] Table 4 Comparison of ablation results of different components
[0124]
[0125] Table 5 Experimental results of different backbone networks
[0126]
[0127] Table 4 shows the evaluation results of different modules of RDSeg on the MPDD dataset. The “-” in the reverse distillation module means that the knowledge distillation structure uses the traditional forward knowledge distillation paradigm. The “-” in the difference-guided synchronization module means that only the cosine similarity attention is used to replace the difference-guided synchronization module of the present invention. From the results in Table 4, it can be seen that the use of the reverse distillation module and the difference-guided synchronization module alone significantly improves the defect detection and defect location performance of the model compared to the basic model. The combination of the two is more effective than using them alone, which proves the effectiveness of each component of the present invention.
[0128] Table 5 shows the impact of different backbone networks on defect detection and location performance. The experimental results show that with the increase of backbone network parameters, the accuracy rate generally presents a stable upward trend, proving the robustness of the method of the present invention.
[0129] The above are preferred embodiments of the present invention. Any changes made according to the technical solution of the present invention, as long as the resulting functions do not exceed the scope of the technical solution of the present invention, belong to the protection scope of the present invention.
Claims
1. A workpiece defect detection method based on reverse distillation and auxiliary segmentation, characterized in that: include: The normal image is used to produce a pseudo defect image and a corresponding mask image by using a fractal anomaly generation method; Sending normal images and pseudo-defect images to a workpiece defect detection model for training, thereby obtaining a workpiece defect detection model that can distinguish normal images from defect images and locate defect positions in defect images; Based on the trained workpiece defect detection model, workpiece defect detection and defect location of the input image to be detected are realized; The workpiece defect detection model includes a pre-trained teacher encoder with frozen weights, a multi-scale feature fusion module, a student decoder, a difference-guided synchronization module, and an end-to-end semantic segmentation network; The training process of the workpiece defect detection model is as follows: (1) Reverse distillation: For the normal input image X nor , Pseudo defect image X defect ,The multi-scale teacher features are obtained by extracting features through the pre-trained teacher encoder with frozen weights; The multi-scale teacher features are input into the multi-scale feature fusion module for multi-scale feature fusion to obtain multi-scale fusion features, and the high-dimensional features are projected into the low-dimensional feature space through the residual module to obtain compact low-dimensional embedded features. Then, the multi-scale student features are obtained by using the reverse structure of the pre-trained teacher encoder with frozen weights as the student decoder; For teacher features and student features, the cosine similarity along the channel dimension is calculated as the reverse distillation loss ; When the input image is a normal image, the student decoder is in the reverse distillation loss To reconstruct the normal image features under the guidance of , so as to imitate the feature extraction ability of the pre-trained teacher encoder with frozen weights for normal images during the training process; (2) Auxiliary segmentation: Using pseudo defect images X defect and the corresponding mask image Mask By designing a difference-guided synchronization module to apply adaptive difference weights and cosine difference attention on student features, we obtain the weighted attention features of student features; we introduce an end-to-end semantic segmentation network to perform defect segmentation on the weighted attention features of student features, obtain the segmentation prediction image, and calculate the segmentation prediction loss of the mask image and the segmentation prediction image corresponding to the pseudo defect image , and then update the workpiece defect detection model parameters through back propagation to obtain a workpiece defect detection model that can distinguish normal images from defect images and locate the defect position in the defect image; The reverse distillation is specifically implemented as follows: For the normal input image X nor , the multi-scale teacher features are obtained by feature extraction through the pre-trained teacher encoder with frozen weights, which is defined as follows: in, E k Indicates k Pre-trained teacher encoder with frozen layer weights, k∈(1,2,3) ; The multi-scale teacher features are input into the multi-scale feature fusion module for multi-scale feature fusion to obtain multi-scale fusion features, and the high-dimensional features are projected into the low-dimensional feature space through the residual module to obtain compact low-dimensional embedded features. Then, the multi-scale student features are obtained by using the reverse structure of the pre-trained teacher encoder with frozen weights as the student decoder. The whole process is defined as follows: in, D k Indicates k layer student decoder, out Represents the output of the multi-scale feature fusion module, BN represents batch normalization operation, and Relu is an activation function; Characteristics of teachers and student characteristics , and calculate its cosine similarity along the channel dimension as the reverse distillation loss , defined as follows: in, M k Indicates k Characteristics of teachers at the first level and k The cosine similarity of the student features of the layer, M k It is expressed as follows: in, h k 、w k Respectively represent k The height and width of the teacher feature / student feature of the layer, T is the transposed sign; When the input image is a normal image, the student decoder performs well in the back distillation loss. To reconstruct the normal image features under the guidance of , so as to imitate the feature extraction ability of the pre-trained teacher encoder with frozen weights for normal images during the training process; For pseudo defect images X defect Execution and normal image X nor The same operation is performed to obtain the teacher characteristics and student characteristics ; The auxiliary segmentation is specifically implemented as follows: (2.1) Design a difference-guided synchronization module to amplify the teacher features of pseudo-defect images and student characteristics The difference between them makes the workpiece defect detection model focus on the key features among the teacher-student features; specifically as follows: First, we introduce cosine difference attention to calculate the key difference between teacher and student features. The cosine difference attention is defined as follows: in, Cosatt k Indicates k cosine difference attention of layer teacher-student features; Secondly, an adaptive difference weight module is designed between the teacher network and the student network to assign a difference weight to each channel of the absolute difference between the teacher and student features. The difference weight is defined as follows: Among them, ADWM is the adaptive difference weight module. abs(·) represents the calculation of the absolute difference between teacher and student characteristics, Weight k Indicates k Adaptive difference weights of teacher-student characteristics at different levels; Finally, by Apply adaptive difference weight and cosine difference attention to get the weighted attention feature of student feature: in, Indicates k The weighted attention features of the student features at the layer, k∈(1,2,3) ; (2.2) Introduce an end-to-end semantic segmentation network to perform defect segmentation on the weighted attention features of the student features, obtain the segmentation prediction image, and calculate the segmentation prediction loss of the mask image and the segmentation prediction image corresponding to the pseudo defect image : in, , They are Dice loss and binary cross entropy loss, Pre=SF(f s ) is the segmentation prediction image output by the end-to-end semantic segmentation network, SF represents the end-to-end semantic segmentation network, f s is a list of three weighted attention features of different sizes; Based on segmentation prediction loss , the workpiece defect detection model parameters are updated by back propagation, and a workpiece defect detection model is obtained which can distinguish normal images from defective images and locate the defect position in the defective image.
2. The workpiece defect detection method based on reverse distillation and auxiliary segmentation according to claim 1, characterized in that: The frozen weight pre-trained teacher encoder uses the outputs of the first three layers of WideResNet50 pre-trained on the ImageNet dataset as the outputs of the frozen weight pre-trained teacher encoder.
Citation Information
Patent Citations
Knowledge distillation method based on semantic segmentation intra-class feature difference
CN111062951A
Combined learning model training method, device and system based on bidirectional knowledge distillation
CN117313832A
Industrial anomaly detection method and system based on multi-teacher network knowledge distillation
CN117609925A
Improved DeSTSeg-based unsupervised grain defect anomaly detection method
CN118469912A
Surrogate hierarchical machine-learning model to provide concept explanations for a machine-learning classifier
US20230031512A1
