Anomaly detection methods, devices, equipment, and storage media based on distillation learning

By combining the Teacher-Student framework and the Reconstructor network, the problems of low pixel-level anomaly detection accuracy and insufficient robustness in existing methods are solved, achieving higher accuracy and robustness in anomaly detection.

CN117079008BActive Publication Date: 2025-12-02TSINGHUA UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310875823.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-17
Publication Date
2025-12-02
Estimated Expiration
2043-07-17

AI Technical Summary

Technical Problem

Existing pixel-level anomaly detection methods based on distillation learning suffer from low accuracy and poor robustness when dealing with anomalous data. In particular, the feature pyramid method is not robust enough when detecting multi-scale anomalies, and the Student model fails to effectively reconstruct normal images.

Method used

By employing the Teacher-Student framework and the Reconstructor network, and through feature map normalization and feature processing strategies, combined with L2 norm and loss function, the consistency of the feature spaces of the Teacher and Student models is ensured. The Reconstructor network is then used to reconstruct the feature maps, enabling multi-scale feature learning and anomaly detection.

Benefits of technology

It improves the accuracy and robustness of pixel-level anomaly detection, effectively detecting anomalies of different scales and enhancing the model's detection capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117079008B_ABST
    Figure CN117079008B_ABST
Patent Text Reader

Abstract

This application relates to an anomaly detection method, apparatus, device, and storage medium based on distillation learning. The method includes: acquiring anomaly detection data of a target; inputting the anomaly detection data into a Teacher-Student framework to obtain multiple pairs of feature maps, and normalizing the multiple pairs of feature maps based on a preset feature processing strategy; inputting the pair of feature maps with the lowest resolution from the multiple pairs of feature maps into a pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps; subtracting each pair of reconstructed feature maps to obtain an anomaly map; and obtaining the anomaly detection result of the anomaly detection image data based on the anomaly map and the reconstructed feature anomaly map. This solves the problems of low accuracy and poor robustness in existing pixel-level anomaly detection methods based on distillation learning when dealing with anomaly data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of distillation learning technology, and in particular to an anomaly detection method, apparatus, device and storage medium based on distillation learning. Background Technology

[0002] Anomaly detection can be categorized into supervised learning and unsupervised learning based on the level of supervision. Supervised learning methods require a large amount of anomaly data to train the model; however, the amount of anomaly data is insufficient, and manual annotation is costly. Unsupervised anomaly detection can be divided into two categories based on the detection target: image-level anomaly detection and pixel-level anomaly detection. The goal of image-level anomaly detection is to perform binary classification on an image to determine whether anomalies exist. The goal of pixel-level anomaly detection is to determine whether each pixel in the image is an anomaly region.

[0003] There are three methods for image-level anomaly detection: generative models, data distribution, and classification methods. Generative model-based methods detect anomalies based on the degree of reconstruction loss. Distribution-based methods consider samples that deviate from the normal data distribution as anomalous. When generating a probability distribution that only contains the probability of normal products, the probability density of anomalous images is very low, thus enabling the classification of anomalous data. Classification-based methods are anomaly detection methods that combine geometric transformations and classification. The classification accuracy for unknown anomalous data is poor, thus enabling the detection of anomalous samples. The above methods can distinguish between normal and anomalous images, but they cannot effectively locate the abnormal pixel positions in anomalous images.

[0004] Pixel-level anomaly detection targets each individual pixel, making it more challenging than image-level anomaly detection. The main methods for pixel-level anomaly detection are based on generative models, such as Generative Adversarial Networks (GANs) and Autoencoders (AEs). In recent years, techniques combining GANs and AEs have been developed for pixel-level anomaly detection; however, all these methods require generative models and high-precision reconstruction of normal images. Otherwise, the accuracy of anomaly detection will decrease.

[0005] Currently, there is relatively little exploration of pixel-level anomaly detection methods based on distillation learning. Existing methods mainly focus on the feature distribution of normal or abnormal images, and detect abnormal regions by the difference in distribution during testing. Due to the difficulty in obtaining large amounts of abnormal data and the high cost of manual annotation, most existing methods use images without anomalies as training sets to train the model's ability to extract normal features. The shortcomings of existing methods are as follows:

[0006] 1. When extracting features based on deep models, the resolution is compressed, resulting in the loss of small-scale defect features. Existing methods attempt to solve this problem by using feature pyramids. Typically, features at multiple resolutions are extracted, anomaly maps at each resolution are calculated, and finally the detection result is obtained by multiplying multiple anomaly maps. Although feature pyramids can detect anomalies at multiple scales, when the detection of an anomaly map is incorrect or the accuracy is low, it will affect the final result, resulting in poor robustness.

[0007] 2. Existing methods mainly focus on how to train the Student model to effectively learn features, but do not have the ability to reconstruct normal images like generative models. Convolutional neural networks will cause feature loss from high dimension to low dimension when extracting features. The Student model only focuses on the consistency between the feature space and the Teacher model when learning features, and does not consider the consistency when reconstructing images from features.

[0008] In summary, existing pixel-level anomaly detection methods based on distillation learning suffer from low accuracy and poor robustness when dealing with anomalous data, and these issues urgently need to be addressed. Summary of the Invention

[0009] This application provides an anomaly detection method, apparatus, device, and storage medium based on distillation learning, to solve the problems of low accuracy and poor robustness of existing pixel-level anomaly detection methods based on distillation learning when faced with anomalous data.

[0010] The first aspect of this application provides an anomaly detection method based on distillation learning, comprising the following steps: collecting anomaly detection data of a target; inputting the anomaly detection data into a Teacher-Student framework to obtain multiple pairs of feature maps, normalizing the multiple pairs of feature maps based on a preset feature processing strategy, and inputting the pair of feature maps with the lowest resolution among the multiple pairs of feature maps into a pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps, subtracting each pair of reconstructed feature maps to obtain an anomaly map, and obtaining the anomaly detection result of the anomaly detection image data based on the anomaly map and the reconstructed feature anomaly map.

[0011] Optionally, in one embodiment of this application, before inputting the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and normalizing the multiple pairs of feature maps based on a preset feature processing strategy, the method further includes: acquiring training detection images that meet preset conditions; inputting the training detection images into the Teacher model to obtain a first feature map; and training the Reconstructor network based on the first feature map.

[0012] Optionally, in one embodiment of this application, the step of inputting the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and normalizing the multiple pairs of feature maps based on a preset feature processing strategy, includes: inputting the detection images that meet the preset conditions into the pre-trained Teacher model and the Student model to be trained, respectively, to obtain the multiple pairs of feature maps; normalizing each pixel of each pair of feature maps based on the channel dimension using the L2 norm; and constructing a first loss function based on the normalization result to maintain the consistency of the feature spaces of the Teacher model and the Student model.

[0013] Optionally, in one embodiment of this application, after inputting the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and normalizing the multiple pairs of feature maps based on a preset feature processing strategy, the method further includes: processing the detection images that meet preset conditions through preset network layers in the Teacher model and Student model to obtain corresponding second feature maps; inputting the second feature maps into the Reconstructor network to obtain the reconstructed features corresponding to the Teacher model and Student model respectively; fixing the parameters of the Reconstructor network and constructing a second loss function to maintain the consistency of the reconstructed image feature space between the Teacher model and the Student model; and constructing a total loss function based on the first loss function and the second loss function to supervise the training of the Student model.

[0014] Optionally, in one embodiment of this application, the mathematical representation of the total loss function is as follows:

[0015] L=γ1L1+γ2L2

[0016] Where L1 is the weighted loss of all feature maps, γ1 is the coefficient of the L1 loss function, L2 is the feature reconstruction loss function, and γ2 is the coefficient of the L2 loss function.

[0017] A second aspect of this application provides an anomaly detection device based on distillation learning, comprising: a first acquisition module for acquiring anomaly detection data of a target; a processing module for inputting the anomaly detection data into a Teacher-Student framework to obtain multiple pairs of feature maps, and normalizing the multiple pairs of feature maps based on a preset feature processing strategy; and a detection module for inputting the pair of feature maps with the lowest resolution from the multiple pairs of feature maps into a pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps, subtracting each pair of reconstructed feature maps to obtain an anomaly map, and obtaining anomaly detection results of the anomaly detection image data based on the anomaly map and the reconstructed feature anomaly map.

[0018] Optionally, in one embodiment of this application, it further includes: a second acquisition module, used to acquire training detection images that meet preset conditions before inputting the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps and normalizing the multiple pairs of feature maps based on a preset feature processing strategy; a first feature extraction module, used to input the training detection images into the Teacher model to obtain a first feature map; and a training module, used to train the Reconstructor network based on the first feature map.

[0019] Optionally, in one embodiment of this application, the processing module includes: a second feature extraction module, used to input the detection images that meet preset conditions into the pre-trained Teacher model and the Student model to be trained, respectively, to obtain the multiple pairs of feature maps; a normalization module, used to normalize each pixel of each pair of feature maps based on the channel dimension using the L2 norm; and a function construction module, used to construct a first loss function based on the normalization result to maintain the consistency of the feature spaces of the Teacher model and the Student model.

[0020] Optionally, in one embodiment of this application, it further includes: a third feature extraction module, used to input the anomaly detection data into a Teacher-Student framework to obtain multiple pairs of feature maps, and after normalizing the multiple pairs of feature maps based on a preset feature processing strategy, process the detection images that meet the preset conditions through preset network layers in the Teacher model and Student model to obtain corresponding second feature maps; a reconstruction module, used to input the second feature maps into a trained Reconstructor network to obtain the reconstructed features corresponding to the Teacher model and Student model respectively; a parameter fixing module, used to fix the parameters of the trained Reconstructor network and construct a second loss function to maintain the consistency of the reconstructed image feature space of the Teacher model and Student model; and a supervision module, used to construct a total loss function based on the first loss function and the second loss function to supervise the training of the Student model.

[0021] Optionally, in one embodiment of this application, the mathematical representation of the total loss function is as follows:

[0022] L=γ1L1+2L2

[0023] Where L1 is the weighted loss of all feature maps, γ1 is the coefficient of the L1 loss function, L2 is the feature reconstruction loss function, and γ2 is the coefficient of the L2 loss function.

[0024] A third aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the anomaly detection method based on distillation learning as described in the above embodiments.

[0025] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described anomaly detection method based on distillation learning.

[0026] Therefore, the embodiments of this application have the following beneficial effects:

[0027] The embodiments of this application can collect anomaly detection data of the target; input the anomaly detection data into a Teacher-Student framework to obtain multiple pairs of feature maps, and normalize the multiple pairs of feature maps based on a preset feature processing strategy; input the pair of feature maps with the lowest resolution into a pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps, subtract each pair of reconstructed feature maps to obtain an anomaly map, and obtain the anomaly detection result of the anomaly detection image data based on the anomaly map and the reconstructed feature anomaly map, thereby enabling the model to fully learn the feature distribution of normal images at different scales and have the ability to reconstruct normal images, effectively improving the robustness of the model and improving the detection accuracy. Thus, it solves the problems of low accuracy and poor robustness of existing pixel-level anomaly detection methods based on distillation learning when facing anomaly data.

[0028] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0029] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:

[0030] Figure 1 This is a flowchart of an anomaly detection method based on distillation learning provided according to an embodiment of this application;

[0031] Figure 2 A schematic diagram illustrating the execution logic of an anomaly detection method based on distillation learning, provided as an embodiment of this application;

[0032] Figure 3 This is an example diagram of an anomaly detection device based on distillation learning according to an embodiment of this application;

[0033] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0034] Among them, 10-anomaly detection device based on distillation learning, 100-first acquisition module, 200-processing module, 300-detection module, 401-memory, 402-processor, and 403-communication interface. Detailed Implementation

[0035] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.

[0036] The following description, with reference to the accompanying drawings, outlines an anomaly detection method, apparatus, device, and storage medium based on distillation learning, according to embodiments of this application. Addressing the problems mentioned in the background section, this application provides an anomaly detection method based on distillation learning. In this method, anomaly detection data of a target is collected; the anomaly detection data is input into a Teacher-Student framework to obtain multiple pairs of feature maps, and these feature maps are normalized based on a preset feature processing strategy; the pair of feature maps with the lowest resolution is input into a pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps; each pair of reconstructed feature maps is subtracted to obtain an anomaly map; and the anomaly detection result of the anomaly detection image data is obtained based on the anomaly map and the reconstructed feature anomaly map. This allows the model to fully learn the feature distributions of normal images at different scales and has the ability to reconstruct normal images, effectively improving the robustness of the model and increasing detection accuracy. Therefore, this solves the problems of low accuracy and poor robustness in existing pixel-level anomaly detection methods based on distillation learning when dealing with anomaly data.

[0037] Specifically, Figure 1 This is a flowchart of an anomaly detection method based on distillation learning provided in an embodiment of this application.

[0038] like Figure 1 As shown, the anomaly detection method based on distillation learning includes the following steps:

[0039] In step S101, abnormal detection data of the target is collected.

[0040] In the embodiments of this application, image data that needs to be detected for anomalies can be collected first. For example, in industrial vision, image data of fabrics, bearings, etc. can be collected periodically by an industrial camera, thereby providing reliable data support for subsequent detection of possible anomalies, such as abnormal color stains, abnormal loose threads or holes, or abnormal texture structure.

[0041] In step S102, the anomaly detection data is input into the Teacher-Student framework to obtain multiple pairs of feature maps, and the multiple pairs of feature maps are normalized based on a preset feature processing strategy.

[0042] After collecting anomaly detection data, the anomaly detection data can be input into the Teacher network model and Student network model in the Teacher-Student framework, respectively. In this embodiment, the Teacher model is a ResNet-18 network pre-trained on the ImageNet dataset, and the Student model is an untrained ResNet-18 network with the same structure as the Teacher network, thereby obtaining multiple pairs of feature maps. The obtained multiple pairs of feature maps are then normalized using the L2 norm based on the channel dimension, thus providing a data foundation for the subsequent dual consistency between the Teacher model and the Student model.

[0043] Optionally, in one embodiment of this application, before inputting the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and normalizing the multiple pairs of feature maps based on a preset feature processing strategy, the method further includes: acquiring training detection images that meet preset conditions; inputting the training detection images into the Teacher model to obtain a first feature map; and training the Reconstructor network based on the first feature map.

[0044] It should be noted that, before inputting the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, the embodiments of this application also require training the Reconstructor network.

[0045] Specifically, since the Teacher model is a ResNet-18 network pre-trained on the ImageNet dataset, the Reconstructor network has a similar structure to the Teacher network, but the Reconstructor network is arranged in reverse order, and the convolutional layers are replaced with deconvolutional layers. The input of the Reconstructor network is the lowest resolution feature map of the Teacher network, that is, the feature map output by conv5.

[0046] Therefore, embodiments of this application can use normal image training to train the Reconstructor network, and denote the Teacher model as T, the Reconstructor network as R, and the dataset as D = {I1, I2, ... I... n Each image has dimensions w×h×c; for image I k The feature map f output by the conv5 layer of the Teacher model is used as the input of the Reconstructor network. After passing through a series of deconvolutional layers, the image output by the Reconstructor network is I′. kIn embodiments of this application, the L2 loss function can be used for supervision during the training of the Reconstructor network, as shown in the following equation:

[0047]

[0048] Therefore, the embodiments of this application utilize the Teacher network model to train the Reconstructor network, thereby making the image reconstructed by the Reconstructor network based on the feature map similar to the original image, effectively ensuring the performance of subsequent model anomaly detection.

[0049] Optionally, in one embodiment of this application, anomaly detection data is input into a Teacher-Student framework to obtain multiple pairs of feature maps, and the multiple pairs of feature maps are normalized based on a preset feature processing strategy, including: inputting detection images that meet preset conditions into a pre-trained Teacher model and a Student model to be trained, respectively, to obtain multiple pairs of feature maps; normalizing each pixel of each pair of feature maps based on the channel dimension using the L2 norm; and constructing a first loss function based on the normalization result to maintain the consistency of the feature spaces of the Teacher model and the Student model.

[0050] In the embodiments of this application, the ResNet-18 network can generate pyramid-shaped features for the acquired image data. The bottom layer generates high-resolution features that can encode low-level information such as texture and color, while the top layer generates low-resolution features containing contextual information. Different layers in the deep neural network correspond to different receptive fields, which allows the Student network to learn feature information of different resolutions from the Teacher network. This hierarchical feature matching can detect anomalies of different scales.

[0051] It should be noted that the training data for the Teacher-Student framework consists entirely of normal images. The feature maps output by conv2, conv3, and conv4 of the Teacher network are used as the learning targets for the Student network, aiming to minimize the difference between the Student's output on normal images and the Teacher's output. The normal image dataset can be represented as D = {I1, I2, ..., I...} n}, Input image I k The l-th feature map output by Teacher and Student has dimensions w×h×c. and All dimensions are w l ×h l ×d l .

[0052] Specifically, firstly, in this embodiment, the feature maps at all resolutions output by the Student and Teacher classes can be normalized using the L2 norm based on the channel dimension, as shown in the following formula:

[0053]

[0054] Where (i,j) are the position coordinates. and Let be the feature vectors of Teacher and Student at position (i,j).

[0055] This application embodiment can use the L2 loss function for supervision during the Student model training process, thereby reducing the distance between the regularized feature vectors of the Student network model and the Teacher network model. The mathematical expression of the loss function is as follows:

[0056]

[0057] Image I k The loss is a weighted loss of feature maps at all resolutions, and this loss function can be expressed as:

[0058]

[0059] Where, α l The weights are for the l-th feature map.

[0060] Therefore, the embodiments of this application integrate multi-scale feature matching strategies, enabling the Student network to receive multi-level hybrid knowledge from the feature pyramid under better supervision, thereby detecting anomalies of different scales. The difference between the feature pyramids generated by the two networks is used as an evaluation function to calculate the probability of anomalies occurring at each pixel in the image. Thus, the Student model learns the feature representation of the Teacher model on normal images, thereby making the Student network model and the Teacher network model consistent in the extracted feature space.

[0061] Optionally, in one embodiment of this application, after inputting anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and normalizing the multiple pairs of feature maps based on a preset feature processing strategy, the method further includes: processing the detection images that meet preset conditions through preset network layers in the Teacher model and Student model to obtain corresponding second feature maps; inputting the second feature maps into the Reconstructor network to obtain the reconstructed features corresponding to the Teacher model and Student model respectively; fixing the parameters of the Reconstructor network and constructing a second loss function to maintain the consistency of the reconstructed image feature space between the Teacher model and the Student model; and constructing a total loss function based on the first loss function and the second loss function to supervise the training of the Student model.

[0062] It should be noted that, after ensuring the consistency of the feature space, the embodiments of this application can use the feature map output by conv5 in the Student network. As input to the Reconstructor network, the reconstructed features are obtained respectively. Simultaneously, the feature map output from conv5 in the Teacher network is... As input to the Reconstructor network, the reconstructed features are obtained. like Figure 2 As shown.

[0063] It is important to note that the parameters of the Reconstructor network need to be fixed during training to ensure that the reconstructed features when Student features are used as input to the Reconstructor network are consistent with the reconstructed features of the Teacher network model, i.e., minimizing... and The distance between them can be supervised using the L2 loss function in embodiments of this application. The mathematical expression of the loss function is as follows:

[0064]

[0065]

[0066] Therefore, the embodiments of this application use the Teacher-Student framework to extract the knowledge learned by the pre-trained Teacher network into the Student network. The training minimizes the distance between features to make the features extracted by the Student and Teacher consistent, so as to learn the distribution of images without anomalies. Furthermore, the embodiments of this application utilize the Reconstructor model to make the images reconstructed from the Teacher and Student consistent.

[0067] Optionally, in one embodiment of this application, the mathematical representation of the total loss function is as follows:

[0068] L=γ1L1+γ2L2

[0069] Where L1 is the weighted loss of all feature maps, γ1 is the coefficient of the L1 loss function, L2 is the feature reconstruction loss function, and γ2 is the coefficient of the L2 loss function.

[0070] Those skilled in the art will understand that training the Student network model requires simultaneously ensuring consistency in both the feature space and the reconstructed image feature space. Therefore, the total training loss in this embodiment can be defined as a weighted sum of L1 and L2, as shown below:

[0071] L=γ1L1+γ2L2

[0072] Where L1 is the weighted loss of all feature maps, γ1 is the coefficient of the L1 loss function, L2 is the feature reconstruction loss function, and γ2 is the coefficient of the L2 loss function.

[0073] Therefore, the embodiments of this application, by designing a Reconstructor model to reconstruct images and features, can effectively avoid the feature loss problem caused by feature compression by convolutional layers. When training the Student network model, reconstruction consistency is introduced so that the features extracted by the Student network model are consistent with those of the Teacher network model in the reconstructed feature space, thereby increasing the robustness of the model and improving the detection accuracy.

[0074] In step S103, the pair of feature maps with the lowest resolution among multiple feature maps is input into the pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps. The anomaly map is obtained by subtracting each pair of reconstructed feature maps, and the anomaly detection result of the anomaly detection image data is obtained based on the anomaly map and the reconstructed feature anomaly map.

[0075] After training the Reconstructor model to reconstruct the image using the Teacher network model, and jointly training the Student network model using the Teacher network model and the Reconstructor model with fixed parameters, the embodiments of this application can further test the trained model. The testing process is as follows:

[0076] 1. Input the image to be tested I into the Teacher network model and the Student network model to obtain feature maps respectively. and

[0077] 2. Take the first three feature maps from the Teacher and Student network models, subtract them from each other using feature maps of the same resolution, and normalize them according to the channel dimension to obtain three anomaly maps Ω1, Ω2, and Ω3.

[0078]

[0079]

[0080] 3. and Inputting each of the trained Reconstructor models into the reconstructed image I yields the reconstructed image. t and I s ;

[0081] 4. Put I t with I s Subtracting and normalizing according to the channel dimension yields Ω4, and the final output anomaly map is as follows:

[0082] Ω = Ω1·Ω2·Ω3·Ω4.

[0083] Therefore, the embodiments of this application utilize a distillation learning anomaly detection method with dual consistency for testing, and use the differences between the features of the Student network model and the Teacher network model to locate abnormal regions, which can effectively improve the detection accuracy and the robustness of the model for abnormal data.

[0084] According to the anomaly detection method based on distillation learning proposed in this application, the method collects anomaly detection data of the target; inputs the anomaly detection data into a Teacher-Student framework to obtain multiple pairs of feature maps, and normalizes the multiple pairs of feature maps based on a preset feature processing strategy; inputs the pair of feature maps with the lowest resolution into a pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps; subtracts each pair of reconstructed feature maps to obtain an anomaly map; and obtains the anomaly detection result of the anomaly detection image data based on the anomaly map and the reconstructed feature anomaly map. This allows the model to fully learn the feature distribution of normal images at different scales and has the ability to reconstruct normal images, effectively improving the robustness of the model and enhancing the detection accuracy.

[0085] Secondly, with reference to the accompanying drawings, an anomaly detection device based on distillation learning proposed according to an embodiment of this application is described.

[0086] Figure 3 This is a block diagram of an anomaly detection device based on distillation learning according to an embodiment of this application.

[0087] like Figure 3As shown, the anomaly detection device 10 based on distillation learning includes: a first acquisition module 100, a processing module 200, and a detection module 300.

[0088] The first acquisition module 100 is used to acquire anomaly detection data of the target.

[0089] The processing module 200 is used to input anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and normalize the multiple pairs of feature maps based on a preset feature processing strategy.

[0090] The detection module 300 is used to input the pair of feature maps with the lowest resolution from multiple feature maps into a pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps. The anomaly map is obtained by subtracting each pair of reconstructed feature maps, and the anomaly detection result of the anomaly detection image data is obtained based on the anomaly map and the reconstructed feature anomaly map.

[0091] Optionally, in one embodiment of this application, the anomaly detection device 10 based on distillation learning further includes: a second acquisition module, a first feature extraction module, and a training module.

[0092] The second acquisition module is used to acquire training detection images that meet preset conditions before inputting anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps and normalizing the multiple pairs of feature maps based on a preset feature processing strategy.

[0093] The first feature extraction module is used to input the training detection image into the Teacher model to obtain the first feature map.

[0094] The training module is used to train the Reconstructor network based on the first feature map.

[0095] Optionally, in one embodiment of this application, the processing module 200 includes: a second feature extraction module, a normalization module, and a function construction module.

[0096] The second feature extraction module is used to input the detection images that meet the preset conditions into the pre-trained Teacher model and the Student model to be trained, respectively, to obtain multiple pairs of feature maps.

[0097] The normalization module is used to normalize each pixel of each pair of feature maps based on the channel dimension using the L2 norm.

[0098] The function construction module is used to construct the first loss function based on the normalization result to maintain the consistency of the feature spaces of the Teacher model and the Student model.

[0099] Optionally, in one embodiment of this application, the anomaly detection device 10 based on distillation learning in this application embodiment further includes: a third feature extraction module, a reconstruction module, a parameter determination module, and a supervision module.

[0100] The third feature extraction module is used to input anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps. After normalizing the multiple pairs of feature maps based on a preset feature processing strategy, the detection images that meet the preset conditions are processed by the preset network layers in the Teacher model and Student model to obtain the corresponding second feature maps.

[0101] The reconstruction module is used to input the second feature map into the trained Reconstructor network to obtain the reconstructed features corresponding to the Teacher model and the Student model, respectively.

[0102] The parameter fixing module is used to fix the parameters of the trained Reconstructor network and construct a second loss function to maintain the consistency of the image feature space reconstructed by the Teacher model and the Student model.

[0103] The supervision module is used to construct a total loss function based on the first and second loss functions to supervise the training of the Student model.

[0104] Optionally, in one embodiment of this application, the mathematical representation of the total loss function is as follows:

[0105] L=γ1L1+γ2L2

[0106] Where L1 is the weighted loss of all feature maps, γ1 is the coefficient of the L1 loss function, L2 is the feature reconstruction loss function, and γ2 is the coefficient of the L2 loss function.

[0107] It should be noted that the foregoing explanation of the anomaly detection method based on distillation learning also applies to the anomaly detection device based on distillation learning in this embodiment, and will not be repeated here.

[0108] The anomaly detection device based on distillation learning proposed in this application collects anomaly detection data of the target; inputs the anomaly detection data into a Teacher-Student framework to obtain multiple pairs of feature maps, and normalizes the multiple pairs of feature maps based on a preset feature processing strategy; inputs the pair of feature maps with the lowest resolution into a pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps, subtracts each pair of reconstructed feature maps to obtain an anomaly map, and obtains the anomaly detection result of the anomaly detection image data based on the anomaly map and the reconstructed feature anomaly map. This allows the model to fully learn the feature distribution of normal images at different scales and has the ability to reconstruct normal images, effectively improving the robustness of the model and enhancing the detection accuracy.

[0109] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include:

[0110] The memory 401, the processor 402, and the computer program stored on the memory 401 and capable of running on the processor 402.

[0111] When the processor 402 executes the program, it implements the anomaly detection method based on distillation learning provided in the above embodiments.

[0112] Furthermore, electronic devices also include:

[0113] Communication interface 403 is used for communication between memory 401 and processor 402.

[0114] The memory 401 is used to store computer programs that can run on the processor 402.

[0115] The memory 401 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0116] If the memory 401, processor 402, and communication interface 403 are implemented independently, then the communication interface 403, memory 401, and processor 402 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 4The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0117] Optionally, in a specific implementation, if the memory 401, processor 402, and communication interface 403 are integrated on a single chip, then the memory 401, processor 402, and communication interface 403 can communicate with each other through an internal interface.

[0118] Processor 402 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0119] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described anomaly detection method based on distillation learning.

[0120] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0121] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0122] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.

[0123] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0124] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0125] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0126] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0127] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.

Claims

1. An anomaly detection method based on distillation learning, characterized in that, Includes the following steps: Acquire anomaly detection image data of the target; The anomaly detection data is input into the Teacher-Student framework to obtain multiple pairs of feature maps. These feature maps are then normalized based on a preset feature processing strategy. The pair of feature maps with the lowest resolution among the multiple pairs of feature maps is input into the pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps. Each pair of reconstructed feature maps is subtracted to obtain an anomaly map. Based on the anomaly map and the reconstructed feature map, the anomaly detection result of the anomaly detection image data is obtained. The process includes, before inputting the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and normalizing the multiple pairs of feature maps based on a preset feature processing strategy, the following steps are also included: Collect training and detection images that meet preset conditions; The trained detection image is input into the Teacher model to obtain the first feature map; The Reconstructor network is trained based on the first feature map; The step of inputting the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and normalizing the multiple pairs of feature maps based on a preset feature processing strategy, includes: The detected images that meet the preset conditions are respectively input into the pre-trained Teacher model and the Student model to be trained to obtain the multiple pairs of feature maps; Based on the channel dimension, the L2 norm is used to normalize each pixel of each pair of feature maps in the multiple pairs of feature maps; The first loss function is constructed based on the normalization result to maintain the consistency of the feature spaces of the Teacher model and the Student model; After inputting the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and normalizing the multiple pairs of feature maps based on a preset feature processing strategy, the process further includes: The detected images that meet the preset conditions are processed by preset network layers in the Teacher model and Student model to obtain the corresponding second feature maps; The second feature map is input into the Reconstructor network to obtain the reconstructed features corresponding to the Teacher model and the Student model, respectively. The parameters of the Reconstructor network are fixed, and a second loss function is constructed to maintain the consistency of the image feature space reconstructed by the Teacher model and the Student model; Based on the first loss function and the second loss function, a total loss function is constructed to supervise the training of the Student model.

2. The method according to claim 1, characterized in that, The mathematical expression of the total loss function is as follows: in, The weighted loss for all feature maps, for The coefficients of the loss function, For feature reconstruction loss function, for The coefficients of the loss function.

3. An anomaly detection device based on distillation learning, characterized in that, include: The first acquisition module is used to acquire anomaly detection image data of the target; The processing module is used to input the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and to normalize the multiple pairs of feature maps based on a preset feature processing strategy. The detection module is used to input the pair of feature maps with the lowest resolution from the multiple pairs of feature maps into a pre-trained Reconstructor network to obtain multiple pairs of reconstructed feature maps. The anomaly map is obtained by subtracting each pair of reconstructed feature maps, and the anomaly detection result of the anomaly detection image data is obtained based on the anomaly map and the reconstructed feature map. The anomaly detection device based on distillation learning further includes: The second acquisition module is used to acquire training detection images that meet preset conditions before inputting the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps and normalizing the multiple pairs of feature maps based on a preset feature processing strategy. The first feature extraction module is used to input the training detection image into the Teacher model to obtain the first feature map; The training module is used to train the Reconstructor network based on the first feature map; The processing module includes: The second feature extraction module is used to input the detection images that meet the preset conditions into the pre-trained Teacher model and the Student model to be trained, respectively, to obtain the multiple pairs of feature maps; The normalization module is used to normalize each pixel of each pair of feature maps based on the channel dimension using the L2 norm. The function construction module is used to construct the first loss function based on the normalization result to maintain the consistency of the feature spaces of the Teacher model and the Student model; The anomaly detection device based on distillation learning also includes: The third feature extraction module is used to input the anomaly detection data into the Teacher-Student framework to obtain multiple pairs of feature maps, and after normalizing the multiple pairs of feature maps based on a preset feature processing strategy, process the detection images that meet the preset conditions through preset network layers in the Teacher model and Student model to obtain the corresponding second feature maps. The reconstruction module is used to input the second feature map into the trained Reconstructor network to obtain the reconstructed features corresponding to the Teacher model and the Student model, respectively. The parameter fixing module is used to fix the parameters of the trained Reconstructor network and construct a second loss function to maintain the consistency of the image feature space reconstructed by the Teacher model and the Student model. The supervision module is used to construct a total loss function based on the first loss function and the second loss function to supervise the training of the Student model.

4. The apparatus according to claim 3, characterized in that, The mathematical expression of the total loss function is as follows: in, The weighted loss for all feature maps, for The coefficients of the loss function, For feature reconstruction loss function, for The coefficients of the loss function.

5. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the anomaly detection method based on distillation learning as described in any one of claims 1-2.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the anomaly detection method based on distillation learning as described in any one of claims 1-2.

Citation Information

Patent Citations

  • Semi-supervised crowd scene anomaly detection method based on mask transformer

    CN115100599A

  • Image anomaly detection method based on local perception knowledge distillation network

    CN115310555A