Multi-scale perception feature anomaly positioning method based on knowledge distillation and VAE

By introducing multi-scale perceived feature anomaly positioning methods of knowledge distillation and VAE in industrial image anomaly detection, the dual attention module and cloned network are used to solve the problem of image data noise and abnormal samples scarcity, and the detection performance and robustness are improved , more accurate abnormal detection.

CN119206363APending Publication Date: 2024-12-27SHANGHAI UNIV OF ENG SCI
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202411438873.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-15
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Existing industrial image anomaly detection technology has noise and quality problems when processing high-dimensional image data, and the scarcity and diversity of abnormal samples make it difficult for the model to distinguish between normal samples and abnormal samples, affecting detection performance.

Method used

Using multi-scale perceived feature anomaly positioning method based on knowledge distillation and VAE, the dual attention module and cloning network are introduced through reconstruction of image modules and multi-scale abstract knowledge distillation modules, which enhances feature extraction and reconstruction capabilities, and uses teacher models to extract multi-scale features. And generate an abnormal positioning map through the student model.

Benefits of technology

The model's ability to extract features and generate images is improved, robustness and accuracy are enhanced, abnormal features in the image can be captured more effectively, and abnormal detection performance is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119206363A_ABST
    Figure CN119206363A_ABST
Patent Text Reader

Abstract

The invention discloses a multi-scale perception feature anomaly positioning method based on knowledge distillation and VAE, relates to the technical field of industrial image anomaly detection, and is used for unsupervised image surface defect anomaly detection. Comprising the steps of image generation, pixel-level abnormal score calculation, teacher clone network, student encoder, multi-scale feature fusion, abnormal region segmentation and the like. According to the method, useful feature representations are extracted from input data by using a clone network C, activation values of features of each layer are extracted to a VAE encoder, and a multi-level double attention module is introduced for an image reconstruction module. The innovation not only relieves the problem of shallow feature interference existing in the model, but also improves the accuracy of the model for obtaining the image perception features and positioning the abnormality at the pixel level. Finally, the method achieves an excellent anomaly detection effect on a public data set, is obviously improved compared with other VAE methods, and proves the practicability and effectiveness of the method in a real scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of industrial image anomaly detection, and in particular to a multi-scale perceptual feature anomaly positioning method based on knowledge distillation and VAE. Background Art

[0002] Thanks to the advancement of computer vision, machine learning, and deep learning technologies, industrial image anomaly detection (IAD) is gradually realizing intelligent and automated production, and surface defect detection has become a hot topic in the industrial field. Unlike the previous inefficient and costly manual detection, it uses image processing technology to achieve efficient and accurate defect detection, which is of great significance for improving production quality, reducing production costs, and realizing automated production. Despite this, there are still many problems in the actual use of IAD. The high cost of labeling high-dimensional image data, the noise and quality of industrial image data, and the scarcity and diversity of abnormal samples are all difficult to solve. Therefore, IAD currently mainly relies on unsupervised methods. Unsupervised methods have the advantages of strong flexibility, strong adaptability, and the ability to discover new types of anomalies. They are particularly suitable for anomaly detection tasks in industrial environments.

[0003] After Kingma and Welling proposed a generative model called Variational Autoencoder (VAE), reconstruction-based methods have made significant progress. It combines the ideas of autoencoders and variational inference, aims to learn the potential representation of data, reconstructs the input image, and calculates the reconstruction error to determine whether the image is abnormal, with superior interpretability. Later, Dehaene et al. improved the VAE model and proposed VAE-grad, which uses the gradient descent of the energy defined by the reconstruction loss to iteratively guide the reconstruction, thereby overcoming the tendency of VAE to produce fuzzy reconstruction and retaining the normal high-frequency structure, effectively improving the training efficiency and generation quality of the model. However, the latent variable representation learned by the traditional VAE model may not pay enough attention to the abnormal area. During the training process, VAE usually encourages samples in the latent space to be adjacent to each other, which may lead to overly smoothed latent representations. For anomaly detection tasks, this may make it difficult to distinguish the difference between normal and abnormal samples, thereby affecting the performance of anomaly detection.

[0004] Then, in order to improve the reconstruction capability and detection accuracy, in the unsupervised mode of CAVGA, the overall framework of the model uses GAN, the codec uses VAE, and the attention mechanism is introduced into the field of anomaly detection for the first time. This framework encourages the attention map to cover the entire normal area, while suppressing the attention map corresponding to the abnormal class in the training image, which can better capture the characteristics of the anomaly. However, if only normal data is used for training, the model may pay too much attention to the noise or distortion in the normal data, turn a blind eye to the abnormal features in the defective data, and ignore the real anomaly. Summary of the invention

[0005] The present invention provides a multi-scale perceptual feature anomaly localization method based on knowledge distillation and VAE, which solves the above-mentioned technical problems.

[0006] In order to solve the above technical problems, the present invention provides a multi-scale perceptual feature anomaly localization method based on knowledge distillation and VAE, which includes a reconstructed image module and a multi-scale abstract knowledge distillation module. The reconstructed image module is composed of only a set of encoder-decoders, and a dual attention module is integrated after each convolution and deconvolution layer to enhance the extracted features in space and channels.

[0007] The teacher module of the multi-scale abstract knowledge distillation module is composed of a clone network "distilled" from the features of each layer of the expert network pre-trained on ImageNet, and the student module is the encoder part of the image reconstruction module.

[0008] The anomaly localization method described is an unsupervised method, in which the teacher acts as a feature extractor to extract useful multi-scale feature representations from the input data, and then the student transforms these abstract features back to the original data space to generate an image anomaly localization map.

[0009] The unsupervised industrial image anomaly detection method includes the following steps:

[0010] Step S1: obtaining normal samples of image data as training samples, performing data enhancement and preprocessing on them, and dividing the processed data into a training set and a validation set;

[0011] Step S2: Use the training set of step S1 to train the model, and use the validation set of step S1 to evaluate the performance of the model, and finally obtain a trained image anomaly detection model;

[0012] Step S3: pre-process the image to be detected, and then import the image anomaly detection model trained in step S2 to obtain the pixel-level anomaly score and anomaly location map of the image as the result of this anomaly detection.

[0013] Preferably, the preprocessing in step S1 uses the industrial defect dataset MVTec-AD for anomaly detection, and data enhancement includes rotation, flipping and cropping. The data preprocessing is to subsample the input image size to 128x128, and divide the training set and the validation set in a ratio of 8:2.

[0014] Preferably, the model training steps in step S2 are as follows:

[0015] Step S201: input the processed image data into the model for clone network training. The teacher model S of the knowledge distillation model is the pre-trained model VGG16, and the student model is the clone network C;

[0016] The training process of the clone network C uses the Adam optimizer and the unbiased network, and defines and To calculate the total loss for this training, we ensure that the Euclidean distance and directionality of the activation values ​​are minimized.

[0017] Step S202: input the normal samples into the reconstruction module part and the feature extractor part of the model for training respectively. The reconstruction module part obtains the output output and latent variable z of the model, as well as the mean mu and logarithmic variance log_var of the latent variable through forward propagation;

[0018] Step S203: In step S202, in the feature fusion part, the mean square error loss (MSE_loss) loss function is used to calculate the error between the model output and the input data, traverse the source activation vector s_activations and the target activation vector t_activations, input s_activations into the convolution adapter model, and then calculate the mean square error loss with the target activation function, which is accumulated into MSE_loss. The loss function is defined as:

[0019]

[0020] in, is the corresponding key layer number, and D represent the reconstruction loss and regularization term (KL divergence), θ and φ represent the parameters of the encoder and decoder, respectively. φ (z│x) represents the posterior distribution of the latent variable z generated by the encoder, p θ (y i │z) represents the conditional distribution of the decoder to generate the target output y.

[0021] Preferably, the modeling of the test image in the extracted feature space is:

[0022] Xa =x n +e

[0023] f(X a )=f(x n )+e f

[0024] x n ~q n (X n ),

[0025] Where f refers to some transformation of pixels;

[0026] f(X a ) and f(x n ) are used to represent abnormal images X a and the normal image x n Transformations in feature space;

[0027] q n (X n ) refers to the characteristic distribution of normal images, x n ~q n (X n ) represents the normal image x n is from the distribution q n obtained by sampling;

[0028] is a system with mean 0 and variance Gaussian white noise, indicating abnormal X a Relative to normal x n offset.

[0029] Preferably, the encoder and decoder of the reconstructed image module are both fully convolutional network architectures, wherein the dual attention module is composed of a crisscross attention network (CC-Net) and a squeeze and excitation attention network (SE-Net) in series, and a BatchNorm2d layer and a LeakyRelu layer are added after each dual attention layer. The higher-level features in the feature extractor will be decoded in the early layers of the decoder. In terms of fusing multi-scale information, for each feature extraction layer f i , i∈[1..L] approximates its normal dataset distribution as follows:

[0030]

[0031] Preferably, the crisscross attention network (CC-Net) is characterized in that CC-Net is a special spatial attention module, which mainly includes query, key and value convolution layers as well as attention calculation and feature adaptation parts; the input image X is convolved to obtain a reduced-dimensional feature map H, and then two feature maps Q and K are generated through a specific convolution layer, and an attention map A is further generated through an Affinity operation; at the same time, the feature map H is again passed through another convolution layer with a 1x1 filter to generate a feature map V for feature adaptation. Finally, the generated attention map A and feature map V are used to perform a context aggregation operation on the input feature map H to obtain an enhanced local feature representation. To enhance the pixel-by-pixel representation.

[0032] Preferably, in step S2, during the training process, in order to fuse the errors of different layers into a single error map of the same size as the original image, the model obtains a "hat" representation of the error map of each layer by spatially sampling the error map of each layer to the resolution of the original image, and then sums the L error maps in the layer dimension to obtain a single error map of the size of the original image, which is used to measure the difference between the model output and the true label of the original image, and guide the adjustment and optimization of the model parameters; at the same time, 1x1 kernel convolution and spatial bilinear interpolation are used to solve the problem of mismatch between the number of channels and spatial resolution in the feature maps of teachers and students.

[0033] Preferably, in step S3, the anomaly score of the entire image is defined as the sum of the image at each pixel and channel, wherein the anomaly score of the pixel is calculated by calculating the log probability map of each layer, then upsampling each image to the original image size, and summing the layers. By using the anomaly score, the model can perform pixel-level segmentation of abnormal areas on the sample.

[0034] Compared with the related art, the multi-scale perception feature anomaly localization method based on knowledge distillation and VAE provided by the present invention has the following beneficial effects:

[0035] 1. The image anomaly localization method of the present invention introduces a multi-level dual attention module composed of CC-Net and SE-Net in series in the reconstruction module, which effectively enhances the model's ability to extract features and generate images.

[0036] 2. In the multi-scale abstract knowledge distillation module, compared with the previous model that only uses the last layer output, the image anomaly localization method of the present invention uses multiple intermediate layer features for fusion to obtain image perception features while more comprehensively understanding and locating anomalies in the image, effectively enhancing the robustness and accuracy of the model.

[0037] 3. In the multi-scale abstract knowledge distillation module, the image anomaly localization method of the present invention introduces the clone network C as the feature extractor of the model. The present invention can more effectively learn the distribution of non-abnormal images and effectively enhance the performance of the model on specific tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 A schematic diagram of a multi-scale perception feature anomaly localization method based on knowledge distillation and VAE of the present invention;

[0039] Figure 2 A schematic diagram of training a cloning network of the present invention;

[0040] Figure 3 It is a schematic diagram of a reconstruction module in the abnormality positioning method of the present invention;

[0041] Figure 4 A schematic diagram of a dual attention module embedded in a reconstruction module in the anomaly localization method of the present invention;

[0042] Figure 5 It is a schematic diagram of the anomaly localization results in the MVTec-AD data set of the present invention. DETAILED DESCRIPTION

[0043] Embodiment 1, by Figure 1-4 A multi-scale perceptual feature anomaly localization method based on knowledge distillation and VAE is given for unsupervised image surface defect anomaly detection, including image generation, pixel-level anomaly score calculation, teacher clone network, student encoder, multi-scale feature fusion, abnormal area localization and other steps.

[0044] The overall framework of this method includes a reconstruction image model and a multi-scale abstract knowledge distillation module. The reconstruction image module is composed of only a set of encoder-decoders, and a dual attention module is integrated after each convolution and deconvolution layer to enhance the extracted features in space and channels. The teacher module of the multi-scale abstract knowledge distillation module is composed of a clone network "distilled" from the features of each layer of the expert network pre-trained on ImageNet, and the student module is the encoder part of the reconstruction image module.

[0045] Among them, the modeling of the test image in the extracted feature space is:

[0046] X a =x n +e

[0047] f(X a )=f(x n )+e f

[0048] x n ~qn (X n ),

[0049] Where f refers to some transformation of pixels;

[0050] f(X a ) and f(x n ) are used to represent abnormal images X a and the normal image x n Transformations in feature space;

[0051] q n (X n ) refers to the characteristic distribution of normal images, x n ~q n (X n ) represents the normal image x n is from the distribution q n obtained by sampling;

[0052] is a system with mean 0 and variance Gaussian white noise, indicating abnormal X a Relative to normal x n offset.

[0053] Among them, the encoder and decoder of the reconstructed image module are both fully convolutional network architectures, and the dual attention module is composed of a criss-cross attention network (CC-Net) and a squeeze and excitation attention network (SE-Net) in series. BatchNorm2d layer and LeakyRelu layer are added after each dual attention layer. The higher-level features in the feature extractor will be decoded in the early layers of the decoder. In terms of fusing multi-scale information, for each feature extraction layer f i , i∈[1..L] approximates its normal dataset distribution as follows:

[0054]

[0055] The crisscross attention network (CC-Net) is characterized in that CC-Net is a special spatial attention module, which mainly includes query, key and value convolution layers as well as attention calculation and feature adaptation parts; the input image X is convolved to obtain a reduced-dimensional feature map H, and then two feature maps Q and K are generated through a specific convolution layer, and the attention map A is further generated through the Affinity operation; at the same time, the feature map H is again passed through another convolution layer with a 1x1 filter to generate a feature map V for feature adaptation. Finally, the generated attention map A and feature map V are used to perform context aggregation operations on the input feature map H to obtain an enhanced local feature representation. , to enhance the pixel-by-pixel representation.

[0056] The anomaly localization method of the present invention is an unsupervised method, in which the teacher acts as a feature extractor to extract useful multi-scale feature representations from the input data, and then the student transforms these abstract features back to the original data space to generate an image anomaly localization map.

[0057] The unsupervised industrial image anomaly detection method includes the following steps:

[0058] Step S1: obtaining normal samples of image data as training samples, performing data enhancement and preprocessing on them, and dividing the processed data into a training set and a validation set;

[0059] Step S2: Use the training set of step S1 to train the model, and use the validation set of step S1 to evaluate the performance of the model, and finally obtain a trained image anomaly detection model;

[0060] Among them, in step S2, during the training process, in order to fuse the errors of different layers into a single error map of the same size as the original image, the model obtains the "hat" representation of the error map of each layer by spatially sampling the error map of each layer to the resolution of the original image, and then sums the L error maps in the layer dimension to obtain a single error map of the size of the original image, which is used to measure the difference between the model output and the true label of the original image, and guide the adjustment and optimization of the model parameters; at the same time, 1x1 kernel convolution and spatial bilinear interpolation are used to solve the problem of mismatch between the number of channels and spatial resolution in the feature maps of teachers and students.

[0061] Step S3: pre-process the image to be detected, and then import the image anomaly detection model trained in step S2 to obtain the pixel-level anomaly score and anomaly location map of the image as the result of this anomaly detection;

[0062] In step S3, the anomaly score of the entire image is defined as the sum of the map at each pixel and channel, where the anomaly score of the pixel is calculated by calculating the log probability map of each layer, then upsampling each image to the original image size, and summing up the layers. By using the anomaly score, the model can perform pixel-level segmentation of abnormal areas on the sample.

[0063] The multi-scale perception feature anomaly localization method based on knowledge distillation and VAE has the following specific training process:

[0064] Step S101: Use the industrial defect dataset MVTec-AD for anomaly detection. MVTec-AD contains 15 different industrial-grade high-resolution image categories. The total amount of data exceeds 5,300, covering various situations from real industrial scenes. Each category contains its corresponding defects and groundtruth. All images are preprocessed after data enhancement steps such as rotation, flipping and cropping. The images are scaled to 128×128 size. The number of channels of the images is 3-channel RGB color images, and the training set and validation set are divided into 8:2 ratio.

[0065] Step S201: Figure 2 , the processed image data is input into the model for clone network training. The teacher model S of the knowledge distillation model is the pre-trained model VGG16, and the student model is the clone network C. During the training process, we use the Adam optimizer and unbiased network, and define and To calculate the total loss of the training, ensure the minimization and directionality of the Euclidean distance of the activation value, the relevant loss calculation method is as follows:

[0066]

[0067] Among them, the i-th key layer in the network is called CP i (CP 0 represents the original input);

[0068] N i Indicates CP i The number of neurons in a layer, For CP i The activation value of layer j, N CP Indicates the total number of key layers;

[0069] vec(x) is a vectorization function that converts a matrix x of any dimension into a one-dimensional vector;

[0070] The λ value is used to control the trade-off between the similarity loss term and the absolute error term. It is set according to the initial error of each item on the untrained network, thereby affecting the training results of the model.

[0071] Finally, through the intermediate layer knowledge transfer between the teacher and the student, the model parameters of the clone network C are obtained as the feature extractor part of the present invention.

[0072] Step S202: Figure 1 For the overall framework of the present invention, normal samples are respectively input into the reconstruction module part and the feature extractor part of the model for training. The reconstruction module part obtains the output output and latent variable z of the model through forward propagation, as well as the mean mu and logarithmic variance log_var of the latent variable, which are obtained through the interaction between the encoder and the decoder. At the same time, the parameter freezing is implemented on the feature extractor, and only the forward propagation is performed to calculate the output, making full use of the prior knowledge of the teacher model to guide and train students. In the feature fusion part, the mean square error loss (MSE_loss) loss function is used to calculate the error between the model output and the input data, traversing the source activation vector s_activations and the target activation vector t_activations, and s_activations is input into the convolution adapter model and then converted with the target activation function to calculate the mean square error loss, which is accumulated in MSE_loss. At the same time, the KL divergence loss is used to measure the difference between the latent space learned in the variational self-encoder and the standard normal distribution, and the final loss is obtained by adding the sum of the mean square error and the KL divergence loss multiplied by the weight.

[0073] Step S203: define the loss function as:

[0074]

[0075] in, is the corresponding key layer number, and D represent the reconstruction loss and regularization term (KL divergence), θ and φ represent the parameters of the encoder and decoder, respectively. φ (z│x) represents the posterior distribution of the latent variable z generated by the encoder, p θ (y i │z) represents the conditional distribution of the decoder to generate the target output y. The minimization of this loss function is done by the stochastic gradient descent (SGD) optimization algorithm to find the best parameter configuration.

[0076] In particular, the number of training times is set to 100 epochs. In the verification step, an early stopping mechanism is adopted, which is set to 25 epochs. If the model does not improve during this period, the training is stopped.

[0077] In particular, the framework of the reconstruction image module is as follows Figure 3 The detailed structure included is shown in Table 1 below:

[0078]

[0079] Table 1 Overview of the framework structure details of the reconstruction image module

[0080] The specific structure of Dual Attention is as follows Figure 4 , which is composed of CCA-Net and SE-Net in series.

[0081] Step S301: During the testing phase, the model in the present invention is implemented on Pytorch. The image size of the data set varies with the category of the object. The present invention uniformly scales all input images according to 128×128. At the same time, 13,000 images are used for training the five-category texture data set, and 2,000 images are used for training the ten-category object data set. Each category is trained for 100 epochs. The network training process uses the general adam optimizer, the initial learning rate is 1e-4, and the batch size is 8. In order to control the size of the model parameters and prevent overfitting, the weight decay part uses L2 regularization technology, where the weight decay coefficient is 0.0001. In terms of hardware conditions, the experiment uses Intel(R) Xeon(R) Silver 4214R CPU@2.40GHz (12vCPU) and RTX 3080Ti graphics card (12GB VRAM) as the computing platform.

[0082] Step S301: Evaluation index: The area under the receiver operating characteristic curve (AUC-ROC) is used as the pixel-level anomaly detection performance evaluation index. The value range is generally between 0.5 and 1. The larger the value, the better the detection effect. The horizontal and vertical coordinates of the curve represent the false positive rate (FPR) and the true positive rate (TPR). At the same time, we choose to use the value that maximizes the F1 score as the image segmentation threshold. The F1 score takes into account the precision and recall rate, and is used to evaluate the balance of the model between normal and abnormal samples. Finally, we use this threshold to generate the following Figure 5 The abnormal location diagram is shown. The relevant calculation is as follows:

[0083]

[0084] Recall=TPR

[0085]

[0086] The experimental results are shown in Table 2 below:

[0087]

[0088] Table 2 AUROC of pixel-level anomaly detection results of the present invention in MVTec-AD.

Claims

1. A multi-scale perceptual feature anomaly localization method based on knowledge distillation and VAE, comprising an image reconstruction module and a multi-scale abstract knowledge distillation module, characterized in that: The reconstructed image module consists of only a set of encoder-decoders, and incorporates a dual attention module after each convolution and deconvolution layer to enhance the extracted features in space and channels; The teacher module of the multi-scale abstract knowledge distillation module is a clone network "distilled" from the features of each layer of the expert network pre-trained on ImageNet, and the student module is the encoder part of the image reconstruction module. The anomaly localization method described is an unsupervised method, in which the teacher acts as a feature extractor to extract useful multi-scale feature representations from the input data, and then the student transforms these abstract features back to the original data space to generate an image anomaly localization map. The unsupervised industrial image anomaly detection method includes the following steps: Step S1: obtaining normal samples of image data as training samples, performing data enhancement and preprocessing on them, and dividing the processed data into a training set and a validation set; Step S2: Use the training set of step S1 to train the model, and use the validation set of step S1 to evaluate the performance of the model, and finally obtain a trained image anomaly detection model; Step S3: pre-process the image to be detected, and then import the image anomaly detection model trained in step S2 to obtain the pixel-level anomaly score and anomaly location map of the image as the result of this anomaly detection.

2. According to claim 1, a multi-scale perceptual feature anomaly localization method based on knowledge distillation and VAE is characterized in that: In the step S1, the preprocessing uses the industrial defect dataset MVTec-AD for anomaly detection, and the data enhancement includes rotation, flipping and cropping. The data preprocessing is to resample the input image size to 128x128, and divide the training set and the validation set in a ratio of 8:

2.

3. According to claim 1, a multi-scale perceptual feature anomaly localization method based on knowledge distillation and VAE is characterized in that: The model training steps in step S2 are as follows: Step S201: input the processed image data into the model for clone network training. The teacher model S of the knowledge distillation model is the pre-trained model VGG16, and the student model is the clone network C; The training process of the clone network C uses the Adam optimizer and the unbiased network, and defines and To calculate the total loss for this training, we ensure that the Euclidean distance and directionality of the activation values ​​are minimized. Step S202: input the normal samples into the reconstruction module part and the feature extractor part of the model for training respectively. The reconstruction module part obtains the output output and latent variable z of the model, as well as the mean mu and logarithmic variance log_var of the latent variable through forward propagation; Step S203: In step S202, in the feature fusion part, the mean square error loss (MSE_loss) loss function is used to calculate the error between the model output and the input data, traverse the source activation vector s_activations and the target activation vector t_activations, input s_activations into the convolution adapter model, and then calculate the mean square error loss with the target activation function, which is accumulated into MSE_loss. The loss function is defined as: in, is the corresponding key layer number, and D represent the reconstruction loss and regularization term (KL divergence), θ and φ represent the parameters of the encoder and decoder, respectively. φ (z│x) represents the posterior distribution of the latent variable z generated by the encoder, p θ (y i │z) represents the conditional distribution of the decoder to generate the target output y.

4. According to claim 1, a multi-scale perceptual feature anomaly localization method based on knowledge distillation and VAE is characterized in that: The modeling of the test image in the extracted feature space is: X a =x n +e f(X a )=f(x n )+e f Where f refers to some transformation of pixels; f(X a ) and f(x n ) are used to represent abnormal images X a and the normal image x n Transformations in feature space; q n (X n ) refers to the characteristic distribution of normal images, x n ~q n (X n ) represents the normal image x n is from the distribution q n obtained by sampling; is a system with mean 0 and variance Gaussian white noise, indicating abnormal X a Relative to normal x n offset.

5. According to claim 1, a multi-scale perceptual feature anomaly localization method based on knowledge distillation and VAE is characterized in that: The encoder and decoder of the reconstructed image module are both fully convolutional network architectures, in which the dual attention module is composed of a crisscross attention network (CC-Net) and a squeeze and excitation attention network (SE-Net) in series. BatchNorm2d layer and LeakyRelu layer are added after each dual attention layer. The higher-level features in the feature extractor will be decoded in the early layers of the decoder. In terms of fusing multi-scale information, for each feature extraction layer f i,i ∈[1..L] approximates its normal dataset distribution as follows:

6. According to claim 5, a multi-scale perceptual feature anomaly localization method based on knowledge distillation and VAE is characterized in that: The crisscross attention network (CC-Net) is characterized in that CC-Net is a special spatial attention module, which mainly includes query, key and value convolution layers as well as attention calculation and feature adaptation parts; the input image X is convolved to obtain a reduced-dimensional feature map H, and then two feature maps Q and K are generated through a specific convolution layer, and the attention map A is further generated through the Affinity operation; at the same time, the feature map H is again passed through another convolution layer with a 1x1 filter to generate a feature map V for feature adaptation. Finally, the generated attention map A and feature map V are used to perform context aggregation operations on the input feature map H to obtain an enhanced local feature representation. To enhance the pixel-by-pixel representation.

7. The method for locating anomalies based on multi-scale perceptual features and VAE according to claim 1 is characterized in that: In step S2, during the training process, in order to fuse the errors of different layers into a single error map of the same size as the original image, the model obtains the "hat" representation of the error map of each layer by spatially sampling the error map of each layer to the resolution of the original image, and then sums the L error maps in the layer dimension to obtain a single error map of the size of the original image, which is used to measure the difference between the model output and the true label of the original image and guide the adjustment and optimization of the model parameters; at the same time, 1x1 kernel convolution and spatial bilinear interpolation are used to solve the problem of mismatch between the number of channels and spatial resolution in the feature maps of teachers and students.

8. The method for locating anomalies based on multi-scale perceptual features and VAE according to claim 1, characterized in that: In step S3, the anomaly score of the entire image is defined as the sum of the map at each pixel and channel, where the anomaly score of the pixel is calculated by calculating the log probability map of each layer, then upsampling each image to the original image size, and summing the layers. By using the anomaly score, the model can perform pixel-level segmentation of abnormal areas on the sample.

Citation Information

Cited By

  • Production line mask finished product abnormity detection method based on knowledge distillation

    CN120598963A

  • Image generation model construction method and device based on improved GAN, and image generation model application method and device based on improved GAN

    CN120876660A

  • Industrial product visual defect detection method and system based on multitask reverse knowledge distillation

    CN121304671A

  • Defect detecting and positioning method based on regional anomaly generation and multi-level reverse distillation

    CN121527502A

  • Defect detection and positioning method based on regional anomaly generation and multi-level reverse distillation

    CN121527502B