Anomaly detection method based on distillation and memory-guided reconstruction

Through the reconstruction method guided by distillation and memory library, the problems of low accuracy and difficulty in feature construction of traditional industrial anomaly detection in complex noisy environments are solved, high-precision industrial anomaly detection is achieved, and the generalization ability of the reconstruction network is improved.

CN117173131BActive Publication Date: 2025-10-03TIANJIN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311140030.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-05
Publication Date
2025-10-03
Estimated Expiration
2043-09-05

AI Technical Summary

Technical Problem

Traditional industrial anomaly detection methods have low accuracy in complex noisy environments, are difficult to build features that adapt to changing industrial pipelines, and manually adjusting hyperparameters is costly. Existing image reconstruction methods produce fuzzy reconstruction results that make it difficult to distinguish between normal and abnormal samples.

Method used

A reconstruction method based on distillation and memory library guidance is adopted. The normal sample features are extracted through the teacher network and embedded into the memory library. The student network performs feature distillation and fusion. The segmentation network is combined for anomaly detection, and the model is trained using a deep learning framework.

Benefits of technology

The accuracy of anomaly detection is improved, the generalization ability of the reconstructed network is enhanced, the difference between training and test data is reduced, and the effect of anomaly detection is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117173131B_ABST
    Figure CN117173131B_ABST
Patent Text Reader

Abstract

The present invention discloses an anomaly detection method based on distillation and memory-guided reconstruction, relating to the technical field of image anomaly detection. The anomaly detection method based on distillation and memory-guided reconstruction includes the following steps: S1, obtaining a simulated anomaly detection image; S2, building a network architecture; S3, designing an anomaly detection scheme and building an image anomaly detection model based on the designed scheme; S4, training the model using the deep learning Pytorch framework; S5, inputting the image to be detected into the model to obtain an anomaly detection result. The present invention utilizes the proposed anomaly reconstruction method based on distillation and memory-guided reconstruction and the normal image degradation method based on Gaussian noise to elevate image anomaly detection performance to a new level.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image anomaly detection methods, and in particular to an anomaly detection method based on distillation and memory library guided reconstruction. Background Art

[0002] Industrial anomaly detection refers to the process of automatically screening out defective products on production lines by inspecting workpiece samples, reducing manual repetitive labor while ensuring production stability and safety. Traditional industrial anomaly detection methods primarily rely on rules, statistics, and models. These difficulties primarily include the following: Industrial environments are highly complex and subject to various noise interference factors, such as temperature, humidity, and pressure, which can affect sensor data and cause data anomalies. Because data samples of anomalies are difficult to obtain on production lines, the accuracy of traditional methods cannot be guaranteed. Traditional methods often require manual feature and rule construction, which is difficult for highly variable industrial production line data, and subsequent adjustments to various hyperparameters often require significant operational and maintenance costs.

[0003] With the advancement of computer vision algorithms, the use of AI for industrial anomaly detection is becoming increasingly mainstream. This project aims to develop an AI algorithm for industrial anomaly detection that can adaptively model and train for diverse industrial environments, extracting effective features from complex noise interference factors, and significantly improving anomaly detection accuracy. Using techniques such as deep learning, small-sample learning and unsupervised learning can be performed using large amounts of normal data, thus avoiding the problem of insufficient anomaly samples. Using AI algorithms for industrial anomaly detection reduces manual repetitive work while ensuring production stability and safety.

[0004] For anomaly detection methods based on image reconstruction, the distribution of normal data is modeled and areas with higher reconstruction errors are identified as anomalies, because models trained only with normal data cannot reconstruct anomalies. Some researchers use generative models, such as autoencoders and their variants to encode and reconstruct normal data and use generative adversarial networks for training to obtain better reconstructed images. Some researchers use random masks to cover normal data and let the reconstruction network "fill" the missing areas. Some researchers use forged abnormal data to make the reconstruction network repair these abnormal areas to enhance the generalization of the reconstruction network. Anomalies are often reconstructed during repair, and blurred reconstruction results will be caused, making it difficult to distinguish between normal samples and abnormal samples. In view of this, the present invention proposes an anomaly detection method based on distillation and memory library guided reconstruction Summary of the Invention

[0005] The purpose of this invention is to generate high-quality face image restoration results, and on this basis propose an anomaly detection method based on distillation and memory library guided reconstruction.

[0006] In order to achieve the above object, the present invention adopts the following technical solutions:

[0007] The anomaly detection method based on distillation and memory-guided reconstruction specifically includes the following steps:

[0008] S1. Acquire a simulated abnormal image: Given a first normal image I n And the external dataset image T, randomly generate a mask M through Perlin noise, and fuse the first normal image I through the mask M n and external dataset image T, to obtain the simulated abnormal image I a ; Then, randomly select the Gaussian blur kernel k and simulate the abnormal image I a After convolution, we get the degraded image I pa ;

[0009] S2. Build a network framework: Design a lightweight identical teacher network G consisting of an autoencoder t and the student network G responsible for abnormal reconstruction s , a segmentation network G seg And a memory bank Ω for storing reference features, using the teacher network G t , Student Network G s and the memory bank Ω together constitute an abnormal reconstruction framework based on distillation and memory bank guidance, using the student network G s and segmentation network G seg Together they form an anomaly detection framework;

[0010] S3. Design a solution and build a model: Based on the feature priors of normal samples, combined with the simulated abnormal image data and network framework described in S1-S2, design an image anomaly detection solution, and build an image anomaly detection model based on the designed solution. The solution specifically includes the following:

[0011] ① Prior acquisition based on normal sample features: train an autoencoder to reconstruct normal images, and use the obtained autoencoder model as the teacher network G t , using the rich normal sample information to train the student network G s Conduct distillation instructions;

[0012] ② Acquisition of reference features in the memory bank: Randomly select n normal samples as reference samples, and use the teacher network G t The encoder extracts features and embeds the extracted features into the memory bank Ω;

[0013] ③ Feature distillation: The simulated abnormal image I pa Enter Student Network G s , the corresponding normal image I n Enter the teacher network G t First, the input convolution layer is converted into a feature map. After that, the encoder reduces the feature map scale by 2 times through a 3×3 convolution layer with a step size of 2 every two convolution layers. The teacher network G t At each scale, the student network G s Distillation of characteristics;

[0014] ④ Fusion processing of reference features and student network extracted features: The student network G s Extracted feature F q By matching, find the feature F with the highest matching degree in the memory bank Ω m , the F m It is adjusted through the convolution module and then F is added through the spatial attention module. m With F q Fusion is performed to obtain the fused feature F f ;

[0015] ⑤ Output of teacher network and student network: fused feature F f Through the student network G s The decoder reconstructs the second normal image I sr , the first normal image I n Through the Teacher Network G t Reconstructed into the third normal image I tr ;

[0016] ⑥ Abnormal segmentation network processing: the image pair (I sr , I tr ) is input to the segmentation network G seg , get the intermediate probability map M o , the pixel-level anomaly score map is obtained through activation function and pooling operation;

[0017] ⑦ Loss function module design: The teacher network G t , student network G s and segmentation network G seg Jointly optimize through online knowledge distillation loss, reconstruction loss and segmentation loss;

[0018] S4, training model: Use the deep learning Pytorch framework to train the model, traversing the simulated abnormal data set constructed in S1 until the student network G s and segmentation network G seg The loss function converges;

[0019] S5. Output result: Input the data pairs in the missing face image dataset obtained in S1 into the stable model trained in S4 to obtain the face image restoration result.

[0020] Preferably, the S1 specifically includes the following contents:

[0021] Assume that the normal image and the external dataset image used for abnormal simulation are I n and T, the mask generated by Perlin noise is M, then the simulated abnormal operation is as follows:

[0022]

[0023] Where, Represents the opposite value of the binary mask M;

[0024] After the simulation abnormality process is completed, the degradation operation is then performed. The specific operations are as follows:

[0025] I pn =I n *k

[0026] Where k is a randomly selected Gaussian blur kernel;

[0027] The abnormal simulation operation and degradation operation are both probabilistic operations, and the probability values ​​are set to 50% and 70%.

[0028] Preferably, the solution ③ specifically includes the following contents:

[0029] 3.1) Teacher Network G t The encoder extracts the feature maps of the two scales of the normal image, which are respectively denoted as and

[0030] 3.2) Student Network G s The encoder and teacher network G t The encoder structure remains consistent, and the student network G s The encoder is used to extract the feature maps of two scales of the simulated abnormal image, which are respectively denoted as and

[0031] 3.3) Calculate the distillation loss of the two scale features extracted by the teacher network encoder and the student network encoder respectively. The specific calculation formula is:

[0032]

[0033] Where, Represent the characteristics of different levels of the teacher network; Represents the characteristics of different levels of the student network; Ldist represents the distillation loss function;

[0034] 3.4) L dist Back to student network G s , so that the teacher network G t Guide students to network G s Learn the characteristics of normal samples.

[0035] Preferably, the solution ④ specifically includes the following contents:

[0036] 4.1) Feature F extracted by the student network encoder q The matching feature F is obtained by matching with the reference feature in the memory library m , the specific calculation formula of the matching process is:

[0037]

[0038] Where, F ref Represents reference features in the memory bank;

[0039] 4.2) Matching feature F m Through the self-attention module, the self-distribution is combined with F q Pull in; a self-attention module is divided into two branches, one of which is used to extract its own features and consists of three residual blocks. The residual block structure is a 1×1 convolution, a 3×3 convolution and a 1×1 convolution stacked together; the other branch is composed of three identical residual blocks, and finally connected to the Sigmoid activation function to extract the mask;

[0040] 4.3) Matching feature F m After passing through the self-attention module, the feature F extracted by the student network encoder q The splicing is performed on the channel, and then the fused feature F is obtained through the spatial attention module.

[0041] Preferably, the solution ⑤ specifically includes the following contents:

[0042] 5.1) First normal image I n Through the Teacher Network G t , reconstructed into the third normal image I tr ;

[0043] 5.2) The fused feature F f Through the student network G s Decoder, reconstructs the second normal image I sr ;

[0044] 5.3) Compute the teacher network to reconstruct the image I tr and student network to reconstruct image Isr The reconstruction loss between , is calculated as follows:

[0045]

[0046] Where, I n is the first normal image; SSIM is the structural similarity, and its formula is:

[0047] S(x,y)=l(x,y) α c(x,y) β s(x,y) γ

[0048] Among them, α, β, and γ represent the proportion of different features in the SSIM measurement. When α, β, and γ are all 1, there are:

[0049]

[0050] Where μ x and μ y is the average grayscale value, which is obtained by averaging the values ​​of all pixels; σ x and σ y is the grayscale standard deviation.

[0051] Preferably, the solution ⑥ specifically includes the following contents:

[0052] 6.1) Segmentation network G seg Using U-net structure, image pair (I sr , I tr ) Input segmentation network G seg After that, we get a two-channel probability map M o ;

[0053] 6.2) Probability map M o After the Sigmoid activation function, it passes through an average pooling layer with a step size of 1 and a size of 11 to obtain the final anomaly mask map used for detection;

[0054] 6.3) Probability map M o The segmentation loss is calculated between the simulated abnormal mask M and the specific calculation formula is as follows:

[0055]

[0056]

[0057] Where H, W are the height and width of the anomaly mask M respectively; i, j represent the anomaly mask M and the probability map M o The coordinates of the pixel in ; p is the loss factor.

[0058] Compared with the existing technology, the present invention provides an anomaly detection method based on distillation and memory-guided reconstruction, which has the following beneficial effects:

[0059] (1) The present invention proposes an anomaly reconstruction method based on distillation and memory library; the teacher network and the student network are pre-trained by reconstruction on the normal samples of this data set to obtain the feature information of the normal samples, and the teacher network guides the student network to learn to reconstruct the abnormal area through distillation; the teacher extracts the features of the normal samples and embeds them into the memory library, and the features extracted by the student network encoder are obtained by querying the memory library to obtain the most matching normal features, which are fused and reconstructed by the student network encoder.

[0060] (2) The present invention proposes an image degradation method for application in anomaly detection. By randomly blurring the simulated abnormal images, the student network can obtain stronger generalization when reconstructing; the blurred image and the clear image can simulate the situation when the reconstructed network result is relatively blurred during testing, thereby reducing the difference between the input data of the segmentation network during training and the data during testing.

[0061] (3) The experiments conducted based on the present invention show that the proposed method is superior to the current mainstream anomaly detection method; the research and exploration of the present invention can inspire more research on the use of distillation and memory libraries to assist reconstruction and reduce the impact of poor reconstruction quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 This is the overall framework diagram of the anomaly detection method based on distillation and memory-guided reconstruction proposed in the present invention;

[0063] Figure 2 This is a flow chart of feature matching and fusion in Example 1 of the present invention. DETAILED DESCRIPTION

[0064] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0065] Example 1:

[0066] See also Figure 1 , the present invention proposes an anomaly detection method based on distillation and memory-guided reconstruction, comprising the following steps:

[0067] S1. Acquire a simulated abnormal image: Given a first normal image I n And the external dataset image T, randomly generate a mask M through Perlin noise, and fuse the first normal image I through the mask M n and external dataset image T, to obtain the simulated abnormal image I a; Then, randomly select the Gaussian blur kernel k and simulate the abnormal image I a After convolution, we get the degraded image I pa ;

[0068] S2. Build a network framework: Design a lightweight identical teacher network G consisting of an autoencoder t and the student network G responsible for abnormal reconstruction s , a segmentation network G seg And a memory bank Ω for storing reference features, using the teacher network G t , Student Network G s and the memory bank Ω together constitute an abnormal reconstruction framework based on distillation and memory bank guidance, using the student network G s and segmentation network G seg Together they form an anomaly detection framework;

[0069] S3. Design a solution and build a model: Based on the feature priors of normal samples, combined with the simulated abnormal image data and network framework described in S1-S2, design an image anomaly detection solution, and build an image anomaly detection model based on the designed solution. The solution specifically includes the following:

[0070] ① Prior acquisition based on normal sample features: train an autoencoder to reconstruct normal images, and use the obtained autoencoder model as the teacher network G t , using the rich normal sample information to train the student network G s Conduct distillation instructions;

[0071] ② Acquisition of reference features in the memory bank: Randomly select n normal samples as reference samples, and use the teacher network G t The encoder extracts features and embeds the extracted features into the memory bank Ω;

[0072] ③ Feature distillation: The simulated abnormal image I pa Enter Student Network G s , the corresponding normal image I n Enter the teacher network G t First, the input convolution layer is converted into a feature map. After that, the encoder reduces the feature map scale by 2 times through a 3×3 convolution layer with a step size of 2 every two convolution layers. The teacher network G t At each scale, the student network G s Distillation of characteristics;

[0073] ④ Fusion processing of reference features and student network extracted features: The student network G s Extracted feature F q By matching, find the feature F with the highest matching degree in the memory bank Ωm , the F m It is adjusted through the convolution module and then F is added through the spatial attention module. m With F q Fusion is performed to obtain the fused feature F f ;

[0074] ⑤ Output of teacher network and student network: fused feature F f Through the student network G s The decoder reconstructs the second normal image I sr , the first normal image I n Through the Teacher Network G t Reconstructed into the third normal image I tr ;

[0075] ⑥ Abnormal segmentation network processing: the image pair (I sr , I tr ) is input to the segmentation network G seg , get the intermediate probability map M o , the pixel-level anomaly score map is obtained through activation function and pooling operation;

[0076] ⑦ Loss function module design: The teacher network G t , student network G s and segmentation network G seg Jointly optimize through online knowledge distillation loss, reconstruction loss and segmentation loss;

[0077] S4, training model: Use the deep learning Pytorch framework to train the model, traversing the simulated abnormal data set constructed in S1 until the student network G s and segmentation network G seg The loss function converges;

[0078] S5. Output result: Input the data pairs in the missing face image dataset obtained in S1 into the stable model trained in S4 to obtain the face image restoration result.

[0079] The above method further includes the following contents:

[0080] 3.1 Abnormal simulation

[0081] The normal images and external dataset images used for abnormal simulation are I n and T, the mask generated by Perlin noise is M, then the simulated abnormal operation is as follows:

[0082]

[0083] Where, Represents the opposite value of the binary mask M;

[0084] After the simulation abnormality process is completed, the degradation operation is performed as follows:

[0085] I pn =I n *k

[0086] Where k is a randomly selected Gaussian blur kernel. Both the anomaly simulation operation and the degradation operation are probabilistic operations, with the probability values ​​set to 50% and 70% respectively.

[0087] 3.2 Teacher Network G t and student network G s distillation

[0088] The teacher network and the student network adopt the same autoencoder structure and are both pre-trained on normal samples. The teacher network is responsible for extracting features from the memory bank Ω and reconstructing normal samples, while the student network is responsible for simulating the reconstruction of abnormal samples. t The encoder extracts the feature maps of the two scales of the normal image, which are respectively denoted as and Student Network G s The encoder and teacher network G t The encoder structure remains consistent, and the student network G s The encoder is used to extract the feature maps of two scales of the simulated abnormal image, which are respectively denoted as and The teacher network distills the student network so that the student network focuses on reconstructing abnormal areas in the image. The calculation formula for the distillation loss is:

[0089]

[0090] Where, Represent the characteristics of different levels of the teacher network; Represents the features of different levels of the student network. Distillation in the feature extraction stage allows the student network encoder to obtain features that are closer to normal samples before reconstruction.

[0091] 3.3 Memory feature acquisition and fusion

[0092] Features F extracted by the student network encoder q The matching feature F is obtained by matching with the reference feature in the memory library m , the specific calculation formula of the matching process is:

[0093]

[0094] Where, F refRepresents the reference feature in the memory library. Matching feature F m Through the self-attention module, the self-distribution is combined with F q Pull in. A self-attention module is divided into two branches. One branch is used to extract its own features and consists of three residual blocks. The residual block structure is a 1×1 convolution, a 3×3 convolution and a 1×1 convolution stacked together; the other branch is composed of three identical residual blocks, and finally connected to the Sigmoid activation function to extract the mask. Matching feature F m After passing through the self-attention module, the feature F extracted by the student network encoder q Splicing is performed on the channel, and then the fused feature F is obtained through the spatial attention module f After adjustment through the self-attention module, the matching features have a more similar distribution to the features extracted by the student network encoder; the use of image-level matching can obtain continuous semantic information in the features, which is more conducive to reconstructing anomalies.

[0095] 3.4 Reconstruction of Normal Images and Simulated Abnormal Images

[0096] Normal image I n Through the Teacher Network G t , reconstructed into a normal image I tr ; The fused feature F f Through the student network G s Decoder, reconstructs the normal image I sr . Calculate the reconstruction loss between the teacher network reconstructed image and the student network reconstructed image. The specific calculation formula is:

[0097]

[0098] Where, I n is the first normal image; SSIM is the structural similarity, and its formula is:

[0099] S(x,y)=l(x,y) α c(x,y) β s(x,y) γ

[0100] Among them, α, β, and γ represent the proportion of different features in the SSIM measurement. When α, β, and γ are all 1, there are:

[0101]

[0102] Where μ x and μ y is the average grayscale value, which is obtained by averaging the values ​​of all pixels; σ x and σ y is the grayscale standard deviation.

[0103] The reconstruction loss is also passed to the teacher network for optimization to make the training more stable.

[0104] 3.5. Segmentation Network

[0105] The segmentation network uses a simple U-net structure, and the image pair (I sr , I tr )After inputting the segmentation network, a two-channel probability map S is obtained. Probability map M o After the activation function Sigmoid, an average pooling layer with a step size of 1 and a size of 11 is passed to obtain the final abnormal mask map for detection. o The segmentation loss is calculated between the simulated abnormal mask M and the specific calculation formula is as follows:

[0106]

[0107]

[0108] Where H, W are the height and width of the anomaly mask M respectively; i, j represent the anomaly mask M and the probability map M o The coordinates of the pixel in ; p is the loss factor.

[0109] 3.6 Loss Function

[0110] There are three different loss functions during network training: distillation loss L dist , reconstruction loss L rec and segmentation loss L seg , the total loss function is as follows:

[0111] L total =λ d L dist +λ r L rec +λ s L seg

[0112] Where λ d ,λ r and λ s are the weights of each loss respectively.

[0113] Example 2:

[0114] Based on Example 1, but with the following differences:

[0115] The present invention selects four advanced comparison methods trained on the MVTEC dataset, including CutPaste, DRAEM, Padim, and RDADDSR. Please refer to Table 1 for the specific results.

[0116] Table 1 Comparison of quantitative results

[0117]

[0118] As shown in Table 1, each cell displays the image-level AUROC and pixel-level AUROC metrics, respectively, which are used to evaluate the capabilities of image anomaly detection and localization. AUROC is the area under the ROC curve (Receiver Operator Characteristic Curve), plotted at different thresholds with the false positive rate (FPR) on the horizontal axis and the recall rate (TPR) on the vertical axis. For the ROC curve, fewer false positives are better, meaning a high TPR is maintained, and the larger the area under the ROC curve, the better. The best results are highlighted in bold. As can be seen from the table, the method of the present invention achieves superiority across all metrics on average. For each category, the method of the present invention achieves the best performance in image anomaly detection in seven categories and in image anomaly localization in three categories. DRAEM and DSR are both reconstruction-based anomaly detection methods. A comparison shows that the method of the present invention performs better in anomaly reconstruction and detection: on the one hand, the distillation and memory bank enhance the reconstruction capabilities of the student network; on the other hand, the image degradation method proposed in the present invention for anomaly simulation can alleviate the problem of poor reconstruction quality of the reconstruction network. Therefore, the method proposed in the present invention will have better performance.

[0119] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, who makes equivalent replacements or changes based on the technical solution and inventive concept of the present invention, should be covered by the scope of protection of the present invention.

Claims

1. Anomaly detection method based on distillation and memory-guided reconstruction, characterized by: The specific steps include: S1. Acquire a simulated abnormal image: Given a first normal image I n And the external dataset image T, randomly generate a mask M through Perlin noise, and fuse the first normal image I through the mask M n and external dataset image T, to obtain the simulated abnormal image I a ; Then, randomly select the Gaussian blur kernel k and simulate the abnormal image I a After convolution, we get the degraded image I pa ; S2. Build a network framework: Design a lightweight identical teacher network G consisting of an autoencoder t and the student network G responsible for abnormal reconstruction s , a segmentation network G seg And a memory bank Ω for storing reference features, using the teacher network G t , Student Network G s and the memory bank Ω together constitute an abnormal reconstruction framework based on distillation and memory bank guidance, using the student network G s and segmentation network G seg Together they form an anomaly detection framework; S3. Design a solution and build a model: Based on the feature priors of normal samples, combined with the simulated abnormal image data and network framework described in S1-S2, design an image anomaly detection solution, and build an image anomaly detection model based on the designed solution. The solution specifically includes the following: ① Prior acquisition based on normal sample features: train an autoencoder to reconstruct normal images, and use the obtained autoencoder model as the teacher network G t , using the rich normal sample information to train the student network G s Conduct distillation instructions; ② Acquisition of reference features in the memory bank: Randomly select n normal samples as reference samples, and use the teacher network G t The encoder extracts features and embeds the extracted features into the memory bank Ω; ③ Feature distillation: The simulated abnormal image I pa Enter Student Network G s , the corresponding normal image I n Enter the teacher network G t First, the input convolution layer is converted into a feature map. After that, the encoder reduces the feature map scale by 2 times through a 3×3 convolution layer with a step size of 2 every two convolution layers. The teacher network G t At each scale, the student network G s Distillation of characteristics; ④ Fusion processing of reference features and student network extracted features: The student network G s Extracted feature F q By matching, find the feature F with the highest matching degree in the memory bank Ω m , the F m It is adjusted through the convolution module and then F is added through the spatial attention module. m With F q Fusion is performed to obtain the fused feature F f ; ⑤ Output of teacher network and student network: fused feature F f Through the student network G s The decoder reconstructs the second normal image I sr , the first normal image I n Through the Teacher Network G t Reconstructed into the third normal image I tr ; ⑥ Abnormal segmentation network processing: the image pair (I sr , I tr ) is input to the segmentation network G seg , get the intermediate probability map M o , the pixel-level anomaly score map is obtained through activation function and pooling operation; ⑦ Loss function module design: The teacher network G t , student network G s and segmentation network G seg Jointly optimize through online knowledge distillation loss, reconstruction loss and segmentation loss; S4, training model: Use the deep learning Pytorch framework to train the model, traversing the simulated abnormal data set constructed in S1 until the student network G s and segmentation network G seg The loss function converges; S5. Output result: Input the data pairs in the missing face image dataset obtained in S1 into the stable model trained in S4 to obtain the face image restoration result.

2. The anomaly detection method based on distillation and memory-guided reconstruction according to claim 1, characterized in that The S1 specifically includes the following contents: Assume that the normal image and the external dataset image used for abnormal simulation are I n and T, the mask generated by Perlin noise is M, then the simulated abnormal operation is as follows: Where, Represents the opposite value of the binary mask M; After the simulation abnormality process is completed, the degradation operation is then performed. The specific operations are as follows: I pn =I n *k Where k is a randomly selected Gaussian blur kernel; The abnormal simulation operation and degradation operation are both probabilistic operations, and the probability values ​​are set to 50% and 70%.

3. The anomaly detection method based on distillation and memory-guided reconstruction according to claim 1, characterized in that The said plan ③ specifically includes the following contents: 3.1) Teacher Network G t The encoder extracts the feature maps of the two scales of the normal image, which are respectively denoted as and 3.2) Student Network G s The encoder and teacher network G t The encoder structure remains consistent, and the student network G s The encoder is used to extract the feature maps of two scales of the simulated abnormal image, which are respectively denoted as and 3.3) Calculate the distillation loss of the two scale features extracted by the teacher network encoder and the student network encoder respectively. The specific calculation formula is: Where, Represent the characteristics of different levels of the teacher network; Represent the characteristics of different levels of the student network; L dist represents the distillation loss function; 3.4) L dist Back to student network G s , so that the teacher network G t Guide students to network G s Learn the characteristics of normal samples.

4. The anomaly detection method based on distillation and memory-guided reconstruction according to claim 1, characterized in that The said plan ④ specifically includes the following contents: 4.1) Feature F extracted by the student network encoder q The matching feature F is obtained by matching with the reference feature in the memory library m , the specific calculation formula of the matching process is: Where, F ref Represents reference features in the memory bank; 4.2) Matching feature F m Through the self-attention module, the self-distribution is combined with F q Pull in; a self-attention module is divided into two branches, one of which is used to extract its own features and consists of three residual blocks. The residual block structure is a 1×1 convolution, a 3×3 convolution and a 1×1 convolution stacked together; the other branch is composed of three identical residual blocks, and finally connected to the Sigmoid activation function to extract the mask; 4.3) Matching feature F m After passing through the self-attention module, the feature F extracted by the student network encoder q The splicing is performed on the channel, and then the fused feature F is obtained through the spatial attention module.

5. The anomaly detection method based on distillation and memory-guided reconstruction according to claim 1, characterized in that The said plan ⑤ specifically includes the following contents: 5.1) First normal image I n Through the Teacher Network G t , reconstructed into the third normal image I tr ; 5.2) The fused feature F f Through the student network G s Decoder, reconstructs the second normal image I sr ; 5.3) Compute the teacher network to reconstruct the image I tr and student network to reconstruct image I sr The reconstruction loss between , is calculated as follows: Where, I n is the first normal image; SSIM is the structural similarity, and its formula is: S(x,y)=l(x,y) α ·c(x,y) β ·s(x,y) γ Among them, α, β, and γ represent the proportion of different features in the SSIM measurement. When α, β, and γ are all 1, there are: Where μ x and μ y is the average grayscale value, which is obtained by averaging the values ​​of all pixels; σ x and σ y is the grayscale standard deviation.

6. The anomaly detection method based on distillation and memory-guided reconstruction according to claim 1, characterized in that The said scheme ⑥ specifically includes the following contents: 6.1) Segmentation network G seg Using U-net structure, image pair (I sr , I tr ) Input segmentation network G seg After that, we get a two-channel probability map M o ; 6.2) Probability map M o After the Sigmoid activation function, it passes through an average pooling layer with a step size of 1 and a size of 11 to obtain the final anomaly mask map used for detection; 6.3) Probability map M o The segmentation loss is calculated between the simulated abnormal mask M and the specific calculation formula is as follows: Where H, W are the height and width of the anomaly mask M respectively; i, j represent the anomaly mask M and the probability map M o The coordinates of the pixel in ; p is the loss factor; χ represents the focusing parameter, and its value is greater than 0.

Citation Information

Patent Citations

  • Video anomaly detection method based on memory enhanced automatic encoder

    CN113807178A

  • Acupuncture point detection method and device and electronic equipment

    CN114712220A