Robust anomaly detection method and device based on difference perception

By constructing a teacher-student network system, generating difference maps and introducing auxiliary supervision, the problem of inaccurate positioning in anomaly detection of existing methods is solved, and high-performance and robust anomaly detection is achieved.

CN117274187BActive Publication Date: 2025-10-21HUAZHONG UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311211768.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-19
Publication Date
2025-10-21
Estimated Expiration
2043-09-19

AI Technical Summary

Technical Problem

Existing anomaly detection methods have difficulty accurately identifying complex and changeable anomaly patterns when there are fewer abnormal samples than normal samples, and the positioning performance of knowledge distillation-based methods is poor.

Method used

By constructing a teacher network and a student network, using Perlin noise to generate abnormal images, calculating the difference map and fusing the feature maps, and introducing auxiliary supervision, the student network's ability to discriminate abnormal areas is improved and the dependence on synthetic appearance is reduced.

Benefits of technology

It improves the positioning accuracy and robustness of anomaly detection, enhances the model's ability to perceive anomalies of unknown categories, and improves the robustness and performance of self-supervision methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117274187B_ABST
    Figure CN117274187B_ABST
Patent Text Reader

Abstract

The application discloses a kind of robust anomaly detection methods based on difference perception.The method comprises the following steps: the application is composed of teacher network, student network, feature fusion module, segmentation module and auxiliary segmentation module.In training phase, normal image and synthetic abnormal image are input into teacher network and student network respectively, on the one hand, student network is constrained to regress teacher network in normal area, on the other hand, the distance between the features of the two is calculated, and the difference map is obtained, the difference map and student network feature are fused, input into segmentation module, and the segmentation module is constrained to accurately locate anomaly.In addition, the student network feature is also input into the auxiliary segmentation module to improve the perception ability of the student network to the anomaly.In the test phase, input abnormal image, combine the difference map of teacher-student network and the segmentation probability map output by the segmentation module to locate the anomaly.The application combines knowledge distillation and self-supervision, realizes high performance and strong robustness of anomaly detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer vision technology, and more specifically, relates to a robust anomaly detection method and device based on difference perception. Background Art

[0002] Anomaly detection has important applications in many fields, such as video surveillance, medical diagnosis, and autonomous driving. However, in real-world applications, anomalous samples are far fewer than normal samples, limiting the development of supervised methods for anomaly detection. Furthermore, the complexity, variability, and unknown nature of anomaly patterns pose significant challenges to supervised anomaly detection. Consequently, researchers have focused in recent years on developing anomaly detection frameworks based on learning from normal samples.

[0003] Currently, mainstream anomaly detection methods can be divided into three categories: image reconstruction-based methods, self-supervision-based methods, and knowledge distillation-based methods. Image reconstruction-based methods use normal samples to train reconstruction models and detect anomalies through reconstruction errors, but the network sometimes generalizes to abnormal samples and leads to missed detections. Self-supervision-based methods use synthetic abnormal samples to obtain corresponding label information and train segmentation models that are sensitive to the boundaries of abnormal samples. However, during testing, the segmentation model will not be able to locate anomalies for abnormal samples that are significantly different from the synthetic data. Knowledge distillation-based methods include a teacher network and a student network. This type of method aims to allow the student network to imitate the teacher network's feature expression of normal data, and perform anomaly detection based on the difference in the characteristics of the two networks during the test phase. However, the positioning performance of this type of method is often poor. Summary of the Invention

[0004] To address the above-mentioned deficiencies or improvement needs in the existing technology, the present invention provides a robust anomaly detection method based on difference perception, aiming to build a high-performance and robust anomaly detection framework. By constraining the segmentation module to learn a discriminative decision boundary, the localization accuracy of anomaly detection is improved. By introducing a difference map through knowledge distillation, the segmentation module's reliance on synthetic appearance is reduced, thereby improving the robustness of anomaly detection. To achieve the above-mentioned objectives, the present invention provides the following technical solutions:

[0005] According to one aspect of the present invention, a robust anomaly detection method based on difference perception is provided, comprising the following steps:

[0006] Step 1: Prepare the teacher network (1) and the student network (2). Prepare a pre-trained convolutional neural network and fix its parameters as the teacher network (1). Randomly initialize the parameters of the network with the same structure as the student network (2).

[0007] Step 2: Synthesize anomaly samples. First, use the Perlin noise generator to create a noise image. Binarize the noise image to generate an anomaly map. Then, randomly select an anomaly texture source image and perform an enhancement operation. Finally, combine the enhanced texture image with the anomaly map through a mask operation. The mask image is mixed with the input image to synthesize the anomaly image.

[0008] Step 3: Calculate the difference map. Input the normal image (3) and the synthetic abnormal image (4) into the teacher network (1) and the student network (2) respectively, and obtain the multi-level feature maps of the two. Then, calculate the distance between the corresponding level feature maps of the teacher-student network through the similarity function (6) to obtain the corresponding difference map.

[0009] Step 4: Calculate the segmentation probability map. The difference map is fused with the student network (2) features and then input into the segmentation module (8) to obtain the segmentation probability map.

[0010] Step 5: Calculate the auxiliary segmentation probability map. In step 3, only the features of the student network (2) in the normal area are constrained. In order to improve the student network (2)'s ability to distinguish abnormal areas, it is further supervised. The features of the student network (2) are input into the auxiliary segmentation module (9) to obtain the corresponding auxiliary segmentation probability map.

[0011] Step 6: Training phase. On the one hand, the student network (2) is constrained to extract features similar to the corresponding features of the teacher network (1) in the normal area of ​​the synthesized image. On the other hand, the auxiliary segmentation probability map and the segmentation probability map are constrained to accurately regress the synthesized abnormal area.

[0012] Step 7: During the testing phase, the abnormal region is located using the difference map and the segmentation probability map. On the one hand, the segmentation module (8) can generate a discriminative decision boundary between the normal distribution and the abnormal distribution, making the positioning result of the segmentation probability map more accurate; on the other hand, the teacher network (1) and the student network (2) have different performances in the abnormal region, so the difference map generated by the two can also be used to locate the abnormal region.

[0013] In one embodiment of the present invention, step one specifically includes: using the first three stages of the ResNet18 model pre-trained on ImageNet as the teacher network, denoted as Teacher, and using the first three stages of the randomly initialized ResNet18 model as the student network, denoted as Student.

[0014] In one embodiment of the present invention, the step three specifically includes: Input to the teacher network to synthesize abnormal images Input into the student network, and obtain the multi-level feature maps of the two, namely Where i represents the i-th stage, so, Where H and W are the height and width of the image respectively, and C1, C2, and C3 are the number of channels of the first, second, and third stage features respectively.

[0015] Then, the distance between the features of the teacher network (1) and the student network (2) at different stages is calculated by the similarity function (6), and the corresponding difference map is obtained. The similarity function (6) is defined as:

[0016]

[0017] in They represent the feature vectors generated by the teacher network and the student network, respectively, SSIM(·) (x,y) They represent the structural consistency of the feature blocks centered at (x, y). Finally, the difference maps of the three stages are added element by element and smoothed using a 1×1 convolution layer to obtain the final difference map:

[0018]

[0019] Up2 and Up4 represent 2x and 4x upsampling respectively, and Repeat represents the copy operation in the channel dimension, so that the first stage difference map M 1 and the second stage difference map M 2 The number of channels and the difference between the third stage M 3 The number of channels of is equal to that of , and C4 is the number of channels of the final difference map.

[0020] In one embodiment of the present invention, the step 4 specifically includes: using a feature fusion module (7) to fuse the low-dimensional texture information, high-dimensional semantic information of the student network feature map and the abnormality location information of the difference map, specifically:

[0021] Step S4-1, the 1 / 16 resolution feature map output by the student network (2) stage 3 Stacked with the difference map M in the channel dimension It is upsampled to obtain a 1 / 8 resolution fused feature map and the convolution layer is used for dimensionality reduction. The BatchNorm layer performs normalization and ReLu performs activation.

[0022] Step S4-2, the 1 / 8 resolution feature map output by the student network (2) stage 2 Stacked with the fusion feature map obtained in step S4-1 in the channel dimension Deconvolve it to get a 1 / 4 resolution fusion feature map The BatchNorm layer performs normalization and ReLu performs activation.

[0023] Step S4-3, the 1 / 4 resolution feature map output by the student network (2) stage 1 Stacked with the fusion feature map obtained in step S4-2 in the channel dimension It is upsampled to obtain a 1 / 2 resolution fused feature map and the convolution layer is used for dimensionality reduction. The BatchNorm layer performs normalization and ReLu performs activation.

[0024] Preferably, the present invention fuses the difference map with the features extracted by the student network (2) and inputs them into the segmentation module (8). On the one hand, the segmentation network, guided by the difference map, can produce more discriminative expressions, thereby more accurately locating anomalies. On the other hand, the segmentation network is no longer limited by the synthetic appearance, thereby enhancing the perception of anomalies of unknown categories. In the case where the method of synthesizing abnormal images is relatively simple, this strategy greatly improves the robustness of the anomaly detection method.

[0025] In one embodiment of the present invention, the step 4 specifically includes: using the segmentation module (8) to predict and obtain a segmentation probability map, specifically including:

[0026] In step S4-4, the fused features obtained in step S4-3 are upsampled to obtain a fused feature map of the original resolution.

[0027] Step S4-5, use 1×1 convolution to predict the features obtained in step S4-4 pixel by pixel And use the Sigmoid function to activate and get the predicted segmentation probability map M seg .

[0028] In one embodiment of the present invention, the step 5 specifically includes: Input them into the corresponding auxiliary segmentation heads Aux1, Aux2, and Aux3 to obtain the corresponding auxiliary segmentation maps, namely Where i represents the i-th stage.

[0029] In one embodiment of the present invention, step 6 specifically includes: during the training phase, constraining the features extracted by the student network (2) in the normal region to be consistent with the corresponding features of the teacher network (1). Considering that the cross entropy loss only constrains the feature vector in isolation and loses context information, the present invention additionally introduces structural similarity to measure the similarity of the features of the teacher and student networks. The loss function (5) can be expressed as:

[0030]

[0031]

[0032] L kd =L cos +L SSIM

[0033] Where i represents the i-th stage (i∈{1,2,3}), Ω neg Indicates the normal area, N neg represents the total pixels in the normal area, They represent the feature vectors generated by the teacher network (1) and the student network (2), L cos represents the cosine similarity between the two feature maps being compared, They represent the features of the teacher network (1) and the student network (2) in the normal area at the i-th stage respectively. SSIM represents the structural similarity between the two compared feature maps. The closer the SSIM value is to 1, the more similar the two feature maps are.

[0034] In one embodiment of the present invention, in order to make the segmentation head and the student network generate discriminative features for normal and abnormal patterns, the present invention also constrains the auxiliary segmentation probability map and the segmentation probability map to accurately regress the synthesized abnormal area. At the same time, since normal pixels far outnumber abnormal pixels, in order to overcome the imbalance problem of the number of the two, the present invention uses a difficult sample mining strategy. The segmentation module (8) and the auxiliary segmentation module (9) are trained in the same way. Therefore, the loss function (10) and the loss function (11) in the present invention are respectively defined as:

[0035]

[0036]

[0037] Where Sub is a subset sampled from the segmentation probability map, S is a subset sampled from the auxiliary segmentation probability map, and x i 、v i are the abnormal probability values ​​predicted by the segmentation probability map and the auxiliary segmentation probability map at position index i, y i 、u i In the present invention, the label of abnormal pixel is set to 1.

[0038] In one embodiment of the present invention, the step 7 specifically includes: adding the difference map and the segmentation probability map to obtain an abnormal score map. In the above step 4, the final difference map is obtained by upsampling the difference maps of different stages and adding them element by element. In the test phase, the average value of the difference map in the channel dimension is obtained Then compare it with the segmentation probability map M segThe final anomaly score graph is obtained by fusion of the score function (13):

[0039]

[0040] Where G is the Gaussian blur kernel, Up4 means 4 times upsampling, M′ is the difference map after taking the mean, and M s is the segmentation probability map, and λ is the weight parameter.

[0041] According to another aspect of the present invention, a robust anomaly detection device based on difference perception is also provided, comprising at least one processor and a memory, wherein the at least one processor and the memory are connected via a data bus, and the memory stores instructions that can be executed by the at least one processor. After being executed by the processor, the instructions are used to complete the robust anomaly detection method based on difference perception.

[0042] In general, the above technical solutions conceived by the present invention have the following beneficial effects compared with the prior art:

[0043] (1) This paper proposes a robust anomaly detection method based on difference perception, which consists of a teacher network, a student network, a feature fusion module, a segmentation module, and an auxiliary segmentation module. Compared with existing self-supervised methods, this method introduces knowledge distillation to obtain additional difference maps based on the distance between the features extracted by the teacher network and the student network. This reduces the segmentation network's over-reliance on the synthetic anomaly appearance and improves the robustness of the model.

[0044] (2) During the testing phase, the difference map complements the segmentation probability map, further enhancing the robustness of the model. In addition, the present invention also introduces auxiliary supervision to improve the performance of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 This is an overall flow chart of the robust anomaly detection method based on difference perception provided by the present invention. DETAILED DESCRIPTION

[0046] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely for the purpose of explaining the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.

[0047] The present invention provides a robust anomaly detection method based on difference perception, such as Figure 1 As shown, the following steps are included:

[0048] Step 1: Prepare the teacher network (1) and the student network (2). Prepare a pre-trained convolutional neural network and fix its parameters as the teacher network (1), and randomly initialize a network with the same structure as the student network (2).

[0049] Specifically, the first three stages of the ResNet18 model pre-trained on ImageNet are used as the teacher network, denoted as Teacher, and the first three stages of the randomly initialized ResNet18 model are used as the student network, denoted as Student.

[0050] Step 2: Synthesize the abnormal image. First, use the Perlin noise generator to create a noise image. Binarize the noise image to generate an abnormal image. Then, randomly select an abnormal texture source image and perform an enhancement operation. Finally, combine the enhanced texture image with the abnormal image through a mask operation. The mask image is mixed with the input image to synthesize the abnormal image.

[0051] Step 3: Calculate the difference map. Input the normal image (3) and the synthetic abnormal image (4) into the teacher network (1) and the student network (2), and calculate the distance between the corresponding hierarchical feature maps of the teacher-student network through the similarity function (6) to obtain the corresponding difference map.

[0052] Specifically, the normal image Input to the teacher network to synthesize abnormal images Input into the student network, and obtain the multi-level feature maps of the two, namely Where i represents the i-th stage, so, Where H and W are the height and width of the image respectively, C1, C2, and C3 are the number of channels of the first, second, and third stage features respectively, where H×W is set to 256×256, and C1, C2, and C3 are 64, 128, and 256 respectively.

[0053] Then, the distance between the features of the teacher network (1) and the student network (2) at different stages is calculated by the similarity function (6), and the corresponding difference map is obtained. The similarity function (6) is defined as:

[0054]

[0055] in They represent the feature vectors generated by the teacher network and the student network, respectively, SSIM(·) (x,y) They represent the structural consistency of the feature block centered at (x, y), and the size of the feature block is 11×11. Finally, the difference maps of the three stages are added element by element and smoothed using a 1×1 convolution layer to obtain the final difference map:

[0056]

[0057] Up2 and Up4 represent 2x and 4x upsampling respectively, and Repeat represents the copy operation in the channel dimension, so that the first stage difference map M 1 and the second stage difference map M 2 The number of channels and the difference between the third stage M 3 The number of channels of is equal to , C4 is the number of channels of the final difference map, which is set to 256.

[0058] Step 4: Calculate the segmentation probability map. Fuse the features of the student network (2) with the difference map. As the input of the segmentation module (8), the corresponding probability segmentation map is obtained.

[0059] Specifically, step S4-1 is to perform the feature map with a resolution of 1 / 16 of the output of the third stage of the student network (2). Stacked with the difference map M in the channel dimension It is upsampled to obtain a 1 / 8 resolution fused feature map and the convolution layer is used for dimensionality reduction. The BatchNorm layer performs normalization and ReLu performs activation.

[0060] Step S4-2, the 1 / 8 resolution feature map output by the student network (2) stage 2 Stacked with the fusion feature map in the channel dimension Deconvolve it to get a 1 / 4 resolution fusion feature map The BatchNorm layer performs normalization and ReLu performs activation.

[0061] Step S4-3, the 1 / 4 resolution feature map output by the student network (2) stage 1 Stacked with the fusion feature map in the channel dimension It is upsampled to obtain a 1 / 2 resolution fused feature map and the convolution layer is used for dimensionality reduction. The BatchNorm layer performs normalization and ReLu performs activation.

[0062] In step S4-4, the fused features obtained in step S4-3 are upsampled to obtain a fused feature map of the original resolution.

[0063] Step S4-5, use 1×1 convolution to predict the features obtained in step S4-4 pixel by pixel And use the Sigmoid function to activate and get the predicted segmentation probability map M seg .

[0064] Step 5: Calculate the auxiliary segmentation probability map. In step 3, only the feature representation of the student network (2) in the normal area is constrained to be similar. In order to improve the discrimination ability of the student network (2) for abnormal areas, it is further supervised. The features of the student network (2) are input to the auxiliary segmentation module (9) to obtain the corresponding auxiliary segmentation probability map.

[0065] Specifically, the network characteristics of each layer of students Input them into the corresponding auxiliary segmentation heads Aux1, Aux2, and Aux3 to obtain the corresponding auxiliary segmentation maps, namely Where i represents the i-th stage, i∈{1,2,3}.

[0066] Step 6: Training phase. On the one hand, the student network (2) is constrained to extract features similar to the corresponding features of the teacher network (1) in the normal area of ​​the synthesized image. On the other hand, the auxiliary segmentation probability map and the segmentation probability map are constrained to accurately regress the synthesized abnormal area.

[0067] Specifically, during the training phase, the features extracted by the student network (2) in the normal region are constrained to be consistent with the corresponding features of the teacher network (1). Considering that the cross entropy loss only constrains the feature vector in isolation and loses contextual information, the present invention additionally introduces structural similarity to measure the similarity of the features of the teacher and student networks. The loss function (5) can be expressed as:

[0068]

[0069]

[0070] L kd =L cos +L SSIM

[0071] Where i represents the i-th stage (i∈{1,2,3}), Ω neg Indicates the normal area, N neg represents the total pixels in the normal area, They represent the feature vectors generated by the teacher network (1) and the student network (2), L cos represents the cosine similarity between the two feature maps being compared, They represent the features of the teacher network (1) and the student network (2) in the normal area at the i-th stage respectively. SSIM represents the structural similarity between the two compared feature maps. The closer the SSIM value is to 1, the more similar the two feature maps are.

[0072] In addition, in order to make the segmentation head and the student network generate discriminative features for normal and abnormal patterns, the present invention also constrains the auxiliary segmentation probability map and the segmentation probability map to accurately regress the synthesized abnormal area. At the same time, since normal pixels far outnumber abnormal pixels, in order to overcome the imbalance problem of the number of the two, the present invention uses a difficult sample mining strategy. The training methods of the segmentation module (8) and the auxiliary segmentation module (9) are consistent. Therefore, the loss function (10) and the loss function (11) in the present invention are respectively defined as:

[0073]

[0074]

[0075] Where Sub is a subset sampled from the segmentation probability map, S is a subset sampled from the auxiliary segmentation probability map, and x i 、v i are the abnormal probability values ​​predicted by the segmentation probability map and the auxiliary segmentation probability map at position index i, y i 、u i In the present invention, the label of abnormal pixel is set to 1.

[0076] Step 7: During the testing phase, the abnormal region is located using the difference map and the segmentation probability map. On the one hand, the segmentation module (8) can generate a discriminative decision boundary between the normal distribution and the abnormal distribution, making the positioning result of the segmentation probability map more accurate; on the other hand, the teacher network (1) and the student network (2) have different performances in the abnormal region, so the difference map generated by the two can also be used to locate the abnormal region.

[0077] Specifically, the difference map and the segmentation probability map are added together to obtain the abnormal score map. In the above step 4, the final difference map is obtained by upsampling the difference maps of different stages and adding them element by element. In the test phase, the average value of the difference map in the channel dimension is obtained Then compare it with the segmentation probability map M seg The final anomaly score graph is obtained by fusion of the score function (13):

[0078]

[0079] Where G is the Gaussian blur kernel, Up4 means 4 times upsampling, and M ′ is the difference map after taking the mean, M s is the segmentation probability map, λ is the weight parameter, which is set to 3.

[0080] Furthermore, the present invention also provides a robust anomaly detection device based on difference perception, comprising at least one processor and a memory, wherein the at least one processor and the memory are connected via a data bus, and the memory stores instructions that can be executed by the at least one processor, and after being executed by the processor, the instructions are used to complete the robust anomaly detection method based on difference perception.

[0081] The present invention proposes a robust anomaly detection method based on difference perception. A difference map is obtained by calculating the distance between the teacher-student network features, and the difference map and the student network features are fused and input into the segmentation module to generate a segmentation probability map. Finally, the segmentation probability map and the difference map are combined to locate the anomaly. The present invention uses knowledge distillation to introduce the difference map, which reduces the segmentation network's dependence on the synthetic appearance, thereby improving the performance and robustness of the self-supervised model. During the testing phase, the difference map complements the segmentation probability map, further enhancing the robustness of the model. In addition, the present invention also introduces auxiliary supervision to improve the performance of the model. The present invention achieves high-performance and highly robust anomaly detection by combining knowledge distillation and self-supervision.

[0082] It will be easily understood by those skilled in the art that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A robust anomaly detection method based on difference perception, characterized in that: The steps include: Step 1: Prepare the teacher network (1) and the student network (2): Prepare a pre-trained convolutional neural network and fix its parameters as the teacher network (1), and randomly initialize the parameters of the network with the same structure as the student network (2); Step 2: Synthesize anomaly samples: First, use the Perlin noise generator to create a noise image, binarize the noise image to generate an anomaly map, then randomly select an anomaly texture source image and perform an enhancement operation. Finally, combine the enhanced texture image with the anomaly map through a mask operation to obtain a mask image, and mix the mask image with the input image to obtain a synthetic anomaly image. Step 3: Calculate the difference map: Input the normal image (3) into the teacher network (1), and input the synthesized abnormal image (4) into the student network (2), and obtain the multi-level feature maps of the two respectively. Then, calculate the distance between the corresponding level feature maps of the teacher network and the student network through the similarity function (6) to obtain the corresponding difference map; Step 4: Calculate the segmentation probability map: fuse the difference map with the student network (2) features, and then input it into the segmentation module (8) to obtain the segmentation probability map; Step 5: Calculate the auxiliary segmentation probability map: In step 3, only the features of the student network (2) in the normal area are constrained. In order to improve the student network (2)'s ability to distinguish abnormal areas, it is further supervised. The features of the student network (2) are input into the auxiliary segmentation module (9) to obtain the corresponding auxiliary segmentation probability map; Step 6: Training phase: On the one hand, constrain the features extracted by the student network (2) in the normal area of ​​the synthetic abnormal image to be similar to the corresponding features of the teacher network (1); on the other hand, constrain the auxiliary segmentation probability map and the segmentation probability map to accurately regress the synthetic abnormal area; Step 7: During the testing phase, the abnormal area is located using the difference map and the segmentation probability map: on the one hand, the segmentation module (8) generates a discriminative decision boundary for the normal distribution and the abnormal distribution, making the positioning result of the segmentation probability map more accurate; on the other hand, the teacher network (1) and the student network (2) perform inconsistently in the abnormal area, so the difference map generated by the two can also be used to locate the abnormal area.

2. The robust anomaly detection method based on difference perception according to claim 1, characterized in that The step 1 specifically includes: The first three stages of the ResNet18 model pre-trained on ImageNet are used as the teacher network, denoted as , the first three stages of the randomly initialized ResNet18 model are used as the student network, denoted as .

3. The robust anomaly detection method based on difference perception according to claim 1, characterized in that The step three specifically includes: Normal image Input to the teacher network to synthesize abnormal images Input into the student network, and obtain the multi-level feature maps of the two, namely , ,in Indicates the stage, so , ,in are the height and width of the image, are the number of channels for the first, second, and third stage features, respectively; Then, the distance between the features of the teacher network (1) and the student network (2) at different stages is calculated by the similarity function (6), and the corresponding difference map is obtained; where the similarity function (6) is defined as: in Represent the feature vectors generated by the teacher network and the student network respectively, Respectively expressed as The structural consistency of the feature block centered at the center; finally, the difference maps of the three stages are added element by element and used The convolutional layer is smoothed to obtain the final difference map: in Respectively represent 2x and 4x upsampling, Indicates that a copy operation is performed in the channel dimension, so that the first stage difference map and the second stage difference map The number of channels and the difference between the third stage The number of channels is equal, is the number of channels of the final difference map.

4. The robust anomaly detection method based on difference perception according to claim 1, characterized in that The step 4 specifically includes: Step S4-1, the 1 / 16 resolution feature map output by the third stage of the student network (2) and difference graph Stacking in the channel dimension ; Upsample it to get a 1 / 8 resolution fusion feature map, and use the convolution layer to reduce the dimension , BatchNorm layer performs normalization and ReLu performs activation; Step S4-2, the 1 / 8 resolution feature map output by the student network (2) stage 2 Stacked with the fusion feature map in the channel dimension ; Deconvolve it to get a 1 / 4 resolution fusion feature map , BatchNorm layer performs normalization and ReLu performs activation; Step S4-3, the 1 / 4 resolution feature map output by the student network (2) stage 1 Stacked with the fusion feature map in the channel dimension ; Upsample it to get a 1 / 2 resolution fusion feature map and use the convolution layer for dimensionality reduction , BatchNorm layer performs normalization and ReLu performs activation; Step S4-4, upsampling the fused features obtained in step S4-3 to obtain a fused feature map of the original resolution; Step S4-5, use 1×1 convolution to predict the features obtained in step S4-4 pixel by pixel , and use the Sigmoid function to activate and get the predicted segmentation probability map .

5. The robust anomaly detection method based on difference perception according to claim 1, characterized in that: The step five specifically includes: The network characteristics of students at each layer Input to the corresponding auxiliary segmentation head respectively The corresponding auxiliary segmentation map is obtained from ,in , .

6. The robust anomaly detection method based on difference perception according to claim 1, characterized in that The step six specifically includes: During the training phase, the features extracted by the student network (2) in the normal region are constrained to be consistent with the corresponding features of the teacher network (1). Considering that the cross entropy loss only constrains the feature vector in isolation and loses context information, the structural similarity is additionally introduced to measure the similarity of the features of the teacher and student networks. The loss function (5) can be expressed as: L kd =L cos +L SSIM in Indicates the stage, , Indicates the normal area, represents the total pixels in the normal area, denote the feature vectors generated by the teacher network (1) and the student network (2), represents the cosine similarity between the two feature maps being compared, Represent the teacher network (1) and the student network (2) The characteristics of the stage in the normal area, represents the structural similarity between the two compared feature maps, The closer the value is to 1, the more similar the two feature maps are.

7. The robust anomaly detection method based on difference perception according to claim 6, characterized in that: In order to make the segmentation head and the student network generate discriminative features for normal and abnormal patterns, the auxiliary segmentation probability map and the segmentation probability map are constrained to accurately regress the synthesized abnormal area; since normal pixels are far more than abnormal pixels, a difficult sample mining strategy is used to overcome the imbalance problem of the number of normal pixels and abnormal pixels; the training method of the segmentation module (8) and the auxiliary segmentation module (9) is the same, and the loss function (10) and the loss function (11) are defined as: in is a subset sampled from the segmentation probability map, is a subset sampled from the auxiliary segmentation probability map, 、 The segmentation probability map and the auxiliary segmentation probability map are respectively at the position index The predicted abnormal probability value at 、 are the corresponding abnormal labels respectively; the label of the abnormal pixel is set to 1.

8. The robust anomaly detection method based on difference perception according to claim 3, characterized in that: The step seven specifically includes: The difference map and the segmentation probability map are added together to obtain the abnormal score map; in the above step 3, the final difference map is obtained by upsampling the difference maps at different stages and adding them element by element. In the test phase, the average value of the difference map in the channel dimension is obtained , and then compare it with the segmentation probability map The final anomaly score map is obtained by fusion of the score function (13): in is the Gaussian blur kernel, Indicates 4 times upsampling, is the difference map after taking the mean, is the segmentation probability map, is the weight parameter.

9. The robust anomaly detection method based on difference perception according to claim 8, characterized in that: Set the value to 3.

10. A robust anomaly detection device based on difference perception, characterized in that: The invention comprises at least one processor and a memory, wherein the at least one processor and the memory are connected via a data bus, and the memory stores instructions that can be executed by the at least one processor, and after the instructions are executed by the processor, they are used to complete the robust anomaly detection method based on difference perception according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Industrial scene unknown type defect segmentation method based on self-supervised heterogeneous network

    CN114742799A

  • Method for detecting defects from inconsistent labels

    CN114972194A