A method for abnormal object segmentation based on distillation comparison
By using the distillation comparison method in abnormal object segmentation and using the difference in semantic features of the teacher branch and the student branch to calculate the anomaly score, the problem of semantic segmentation misjudgment in the existing technology is solved and more accurate abnormal object segmentation is achieved.
Patent Information
- Application Number
- CN202111523499.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-12-14
AI Technical Summary
Existing abnormal object segmentation methods rely heavily on semantic segmentation prediction, which is prone to misjudgment due to classification errors, affecting the accuracy of abnormal object segmentation.
Using an abnormal object segmentation method based on distillation comparison, the teacher branch and the student branch are trained through training images without abnormal objects, and semantic feature distribution distillation is used to ensure that the two branches are consistent on the normal class and inconsistent on the abnormal class, and perform in the test The stage calculates anomaly scores through multi-scale feature extraction and aggregation, and compares the differences in high-level semantic features of the two branches position by position.
It greatly reduces the adverse impact of semantic segmentation errors on the results, improves the accuracy of segmentation of abnormal objects, avoids misjudgment of normal category pixels, and achieves more accurate segmentation of abnormal objects.
Smart Images

Figure CN114170599B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision, and more specifically, relates to an abnormal object segmentation method based on distillation comparison. Background Art
[0002] In recent years, abnormal object segmentation has become a research hotspot in some safety-critical fields, such as autonomous driving and medical image analysis. Deep convolutional neural networks have made significant breakthroughs in semantic segmentation tasks, whose goal is to assign a predefined semantic category label to each pixel. However, in open scenes in the real world, if a pixel belongs to an unknown category, i.e., an abnormal category, it is dangerous to classify it as a class in the predefined normal category instead of the abnormal category. The abnormal object segmentation task is to segment out the abnormal object pixels in the test image that are not in the predefined normal category of the training image.
[0003] Existing abnormal object segmentation methods first use semantic segmentation networks (such as PSPNet) to obtain semantic segmentation predictions, and then use different strategies to obtain anomaly score maps based on the semantic segmentation predictions. Methods based on uncertainty estimation perform different post-processing on semantic segmentation predictions, such as softmax function, CRF (Conditional Random Field) algorithm, semantic segmentation prediction integration, etc. to obtain anomaly score maps; methods based on image reconstruction use semantic segmentation predictions to resynthesize the original image, and compare the resynthesized image with the original image to obtain anomaly score maps. Semantic segmentation prediction is a core step in the inference stage of existing abnormal segmentation methods.
[0004] Most existing abnormal object segmentation methods rely heavily on semantic segmentation prediction, but it is observed that pixels that are misclassified in semantic segmentation are very easy to be misdetected as abnormalities. This phenomenon seriously affects the accuracy of abnormal object segmentation, but it is rarely discussed in existing methods. Summary of the invention
[0005] In response to the above defects or improvement needs of the prior art, the present invention provides a more accurate abnormal object segmentation method based on distillation comparison, which avoids the adverse effects of the introduction of semantic segmentation errors on the results, greatly reduces the misjudgment of normal category pixels caused by semantic segmentation errors, and achieves more accurate segmentation of abnormal objects in images.
[0006] To achieve the above object, the present invention provides an abnormal object segmentation method based on distillation comparison, comprising the following steps:
[0007] Step S1, using training images without abnormal objects and their pixel-level semantic labels to train a semantic segmentation network, removing the classifier of the trained semantic segmentation network and retaining only the feature extraction and aggregation parts as the teacher branch;
[0008] Step S2, fixing the parameters of the teacher branch obtained in step S1, and using semantic feature distribution distillation to train a student branch with a similar structure to the teacher branch on training images without abnormal objects. The semantic feature distribution distillation ensures that the outputs of the two branches are consistent on the normal class and inconsistent on the abnormal class.
[0009] Step S3, input a test image with an abnormal object, and use the teacher branch obtained in step S1 and the student branch obtained in step S2 to perform multi-scale feature extraction and aggregation on the image to obtain high-level semantic features of the image;
[0010] In step S4, the high-level semantic features of the teacher branch and the student branch obtained in step S3 are compared position by position, and the difference in the semantic features of the two branches is calculated using a scoring function as the anomaly score of the position to obtain an anomaly score map. The anomaly score map is bilinearly upsampled to the original image size, and finally a suitable threshold is set to divide all pixels in the image into normal and abnormal categories.
[0011] In one embodiment of the present invention, the semantic segmentation network in step S1 adopts any existing semantic segmentation network.
[0012] In one embodiment of the present invention, the classifier part is removed from the semantic segmentation network as a teacher branch. The teacher branch includes an image feature extraction module and a feature aggregation module. When training the semantic segmentation network, the downsampling operation of the high-level feature extraction module is removed. At the same time, a hole convolution is introduced at the high-level of the feature extraction module to replace the ordinary convolution, so that the output feature map size of the teacher branch is 1 / 8 of the input image, the number of channels is C, and C is a preset value. Finally, each layer of channels is standardized to obtain the final output features of the teacher branch.
[0013] In one embodiment of the present invention, the student branch in step S2 adopts a structure similar to that of the teacher branch in step S1.
[0014] In one embodiment of the present invention, the student branch in step S2 is specifically as follows: the student branch includes an image feature extraction module and a feature aggregation module, the downsampling operation of the high-level feature extraction module is removed, and at the same time, a hole convolution is introduced at the high-level feature extraction module to replace the ordinary convolution, so that the output feature map size of the student branch is 1 / 8 of the input image, which is consistent with the output feature map size of the teacher branch, the number of channels is C, C is a preset value, and is consistent with the number of output feature channels of the teacher branch, and finally each layer of channels is standardized to obtain the final output features of the student branch.
[0015] In one embodiment of the present invention, in step S2, the student branch is trained using semantic feature distribution distillation on a training image without abnormal objects, and the optimized objective function is: Where M is the batch size, C is the number of channels, i,j are the position indexes in the feature map, and c is the channel index in the feature map. It is the difference between the feature values at the corresponding positions of the corresponding channels in the output feature maps of the teacher branch and the student branch.
[0016] In one embodiment of the present invention, during the training phase of the teacher branch and the student branch, the input training images are images without abnormal objects and only contain predefined normal categories.
[0017] In one embodiment of the present invention, the scoring function in step S4 is: Among them, C is the number of channels, i,j is the position index in the feature map, and c is the channel index in the feature map. It is the difference between the feature values at the corresponding positions of the corresponding channels in the output feature maps of the teacher branch and the student branch.
[0018] In one embodiment of the present invention, PSPNet with ResNet-50 as the backbone network is used as the semantic segmentation network.
[0019] In one embodiment of the present invention, M=4, C=512.
[0020] In general, the above technical solution conceived by the present invention has the following beneficial effects compared with the prior art:
[0021] (1) The present invention proposes a novel abnormal object segmentation method based on distillation comparison. In the training phase, the method only uses normal images without abnormalities. In the test phase, the differences in high-level semantic features extracted by the two branches are compared position by position to more effectively detect abnormalities. In the test phase, the prediction of the semantic segmentation network classification head is not used as an intermediate step to avoid the adverse effects of semantic segmentation errors on the results. The misjudgment of normal category pixels caused by semantic segmentation errors is greatly reduced, and more accurate segmentation of abnormal objects in the image is achieved.
[0022] (2) The present invention proposes a simple and flexible abnormal object segmentation method based on distillation comparison, in which the teacher branch can be any semantic segmentation network without the classifier part. The structure of the student branch can be similar to that of the teacher branch. The model size can be selected according to actual requirements, and the method is more universal. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1It is an overall flow chart of the abnormal object segmentation method based on distillation comparison provided by the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain 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 can be combined with each other as long as they do not conflict with each other.
[0025] The present invention provides a method for segmenting abnormal objects based on distillation comparison, such as Figure 1 As shown, the following steps are included:
[0026] Step S1, using training images without abnormal objects (1) and their pixel-level semantic labels to train a semantic segmentation network, removing the classifier of the trained semantic segmentation network and retaining only the feature extraction and aggregation parts as the teacher branch (2);
[0027] Step S2, fix the parameters of the teacher branch obtained in step S1, and train a student branch (3) with a similar structure to the teacher branch using semantic feature distribution distillation on the training image (1) without abnormal objects. The semantic feature distribution distillation ensures that the outputs of the two branches are consistent on the normal class and inconsistent on the abnormal class.
[0028] Step S3, input the test image (5) with the abnormal object, use the teacher branch obtained in step S1 and the student branch obtained in step S2 to perform multi-scale feature extraction and aggregation on the image, and obtain high-level semantic features of the image;
[0029] In step S4, the high-level semantic features of the teacher branch and the student branch obtained in step S3 are compared position by position, and the difference in the semantic features of the two branches is calculated using the scoring function (6) as the anomaly score of the position to obtain an anomaly score map. The anomaly score map is bilinearly upsampled to the original image size, and finally a suitable threshold is set to divide all pixels in the image into normal and abnormal categories.
[0030] There are three main implementation parts: 1) teacher branch; 2) student branch; 3) objective function and scoring function. Next, the steps in the present invention are described in detail.
[0031] 1. Teacher branch
[0032] The embodiment of the present invention adopts PSPNet with ResNet-50 as the backbone network as the semantic segmentation network. On the training set without abnormal objects, PSPNet is trained under the conventional settings of semantic segmentation. The teacher branch (2) in the embodiment removes the classifier part of the trained PSPNet, retains the feature extraction module ResNet-50 for image feature extraction, and the feature aggregation module uses a pyramid pooling module for multi-scale aggregation of high-level semantic features. In order not to lose too much resolution to avoid losing small object information, the embodiment removes the downsampling operation of the last two layers of convolution blocks of ResNet-50. In order to obtain a larger receptive field to obtain more contextual information, the fourth layer convolution block of ResNet-50 is replaced with a dilated convolution block with a dilated rate of 2, and the fifth layer convolution block is replaced with a dilated convolution block with a dilated rate of 4. The output image feature map size is 1 / 8 of the input image. The output features of the last layer of ResNet-50 are pooled at four levels: 1×1, 2×2, 3×3, and 6×6. The pooled features are bilinearly upsampled to 1 / 8 of the input image size and concatenated with the output features of the last layer of ResNet-50. A 1×1 convolution is used to convert the number of concatenated feature channels to C. Finally, each layer of channels is standardized to obtain the final output features of the teacher branch (2). In the embodiment, C is set to 512.
[0033] 2. Student Branch
[0034] The student branch (3) used in the embodiment of the present invention is similar in structure to the teacher branch (2) in the embodiment. ResNet-34 is used as a feature extraction module to extract image features, and a pyramid pooling module is used as a feature aggregation module to perform multi-scale aggregation of high-level semantic features. In order not to lose too much resolution and avoid losing small object information, the downsampling operation of the last two layers of convolution blocks of ResNet-34 is removed in the embodiment. In order to obtain a larger receptive field to obtain more context information, the fourth layer of convolution blocks of ResNet-34 is replaced with a dilated convolution block with a dilated rate of 2, and the fifth layer of convolution blocks is replaced with a dilated convolution block with a dilated rate of 4. The size of the output image feature map is 1 / 8 of the input image. The output features of the last layer of ResNet-34 are pooled at four levels of 1×1, 2×2, 3×3, and 6×6. The pooled features are bilinearly upsampled to 1 / 8 of the size of the input image and connected with the output features of the last layer of ResNet-34. A 1×1 convolution is used to change the number of feature channels after connection to C. Finally, each layer of channels is standardized to obtain the final output features of the student branch. In the embodiment, C is set to 512.
[0035] 3. Objective function and scoring function
[0036] In the stage of training the student branch, the embodiment of the present invention fixes the parameters of the teacher branch, and trains the student branch using semantic feature distribution distillation on a training set without abnormal objects. The optimized objective function (4) is:
[0037]
[0038] Where M is the batch size, C is the number of channels, i,j are the position indexes in the feature map, and c is the channel index in the feature map. It is the difference between the feature values at the corresponding positions of the corresponding channels in the output feature graphs of the teacher branch and the student branch. In this embodiment of the present invention, M=4 and C=512 are set.
[0039] In the test phase of the embodiment of the present invention, a test image with an abnormal object is input, and the teacher branch (2) and the student branch (3) respectively extract high-level semantic features of the test image (5) with an abnormal object after aggregation and compare them position by position. The difference of the semantic features of the two branches is calculated using the scoring function (6) as the abnormal score of the position to obtain an abnormal score map. The scoring function (6) is:
[0040]
[0041] Among them, C is the number of channels, i,j is the position index in the feature map, and c is the channel index in the feature map. It is the difference between the feature values at the corresponding positions of the corresponding channels in the output feature maps of the teacher branch and the student branch. In the embodiment of the present invention, C=512 is set. The semantic feature distribution distillation ensures that the outputs of the two branches are consistent in the normal class, because the training process is only performed on images that only contain predefined normal categories without abnormal objects. For untrained abnormal category pixels, the semantic feature distribution extracted by the two branches is arbitrary, so the output features of the two branches are inconsistent in the abnormal class. For normal category pixels, the abnormal score calculated by the scoring function is small, while for abnormal category pixels, the abnormal score calculated by the scoring function is large.
[0042] The present invention proposes a method for segmenting abnormal objects based on distillation comparison. The distillation comparison network includes a teacher branch and a student branch. On a training set without abnormal objects, the teacher branch is trained under the conventional setting of semantic segmentation, and the student branch is obtained by distilling the semantic feature distribution of the teacher branch. The semantic feature distribution distillation ensures that the outputs of the two branches remain consistent on the normal class and inconsistent on the abnormal class. The difference in semantic features between the two branches is used to effectively detect anomalies in the test phase. The distillation comparison network is simple and flexible. The prediction of the semantic segmentation network classification head is not used as an intermediate step in the test phase, so as to avoid the introduction of semantic segmentation errors that have a negative impact on the results, greatly reduce the misjudgment of normal category pixels with semantic segmentation errors, and achieve more accurate segmentation of abnormal objects in the image.
[0043] It will be easily understood by those skilled in the art that the above description is only 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 protection scope of the present invention.
Claims
1. A method for segmenting abnormal objects based on distillation comparison, characterized in that: The following steps are involved: Step S1, using training images without abnormal objects and their pixel-level semantic labels to train a semantic segmentation network, removing the classifier of the trained semantic segmentation network and retaining only the feature extraction and aggregation parts as the teacher branch; Step S2, fixing the parameters of the teacher branch obtained in step S1, and using semantic feature distribution distillation to train a student branch with a similar structure to the teacher branch on training images without abnormal objects. The semantic feature distribution distillation ensures that the outputs of the two branches are consistent on the normal class and inconsistent on the abnormal class. Step S3, input a test image with an abnormal object, and use the teacher branch obtained in step S1 and the student branch obtained in step S2 to perform multi-scale feature extraction and aggregation on the image to obtain high-level semantic features of the image; In step S4, the high-level semantic features of the teacher branch and the student branch obtained in step S3 are compared position by position, and the difference in the semantic features of the two branches is calculated using a scoring function as the anomaly score of the position to obtain an anomaly score map. The anomaly score map is bilinearly upsampled to the original image size, and finally a suitable threshold is set to divide all pixels in the image into normal and abnormal categories.
2. The abnormal object segmentation method based on distillation comparison according to claim 1, characterized in that: The semantic segmentation network in step S1 may adopt any existing semantic segmentation network.
3. The abnormal object segmentation method based on distillation comparison according to claim 1 or 2, characterized in that: In the semantic segmentation network, the classifier part is removed as the teacher branch. The teacher branch includes the image feature extraction module and the feature aggregation module. When training the semantic segmentation network, the downsampling operation of the high-level feature extraction module is removed. At the same time, the hole convolution is introduced at the high-level of the feature extraction module to replace the ordinary convolution, so that the output feature map of the teacher branch has a size of 1 / 8 of the input image and the number of channels is C, where C is a preset value. Finally, each layer of channels is standardized to obtain the final output features of the teacher branch.
4. The abnormal object segmentation method based on distillation comparison according to claim 1 or 2, characterized in that: The student branch in step S2 adopts a structure similar to that of the teacher branch in step S1.
5. The abnormal object segmentation method based on distillation comparison according to claim 4, characterized in that: The student branch in step S2 is specifically: The student branch includes an image feature extraction module and a feature aggregation module. The downsampling operation of the high-level feature extraction module is removed, and atrous convolution is introduced at the high-level feature extraction module to replace ordinary convolution, so that the output feature map size of the student branch is 1 / 8 of the input image, which is consistent with the output feature map size of the teacher branch. The number of channels is C, which is a preset value and consistent with the number of output feature channels of the teacher branch. Finally, each layer of channels is standardized to obtain the final output features of the student branch.
6. The abnormal object segmentation method based on distillation comparison according to claim 1 or 2, characterized in that: In step S2, the student branch is trained using semantic feature distribution distillation on the training image without abnormal objects, and the optimized objective function is: Where M is the batch size, C is the number of channels, i,j are the position indexes in the feature map, and c is the channel index in the feature map. It is the difference between the feature values at the corresponding positions of the corresponding channels in the output feature maps of the teacher branch and the student branch.
7. The abnormal object segmentation method based on distillation comparison according to claim 1 or 2, characterized in that: During the training phase of the teacher branch and the student branch, the input training images are images without abnormal objects and only contain predefined normal categories.
8. The abnormal object segmentation method based on distillation comparison according to claim 1 or 2, characterized in that: The scoring function in step S4 is: Among them, C is the number of channels, i,j is the position index in the feature map, and c is the channel index in the feature map. It is the difference between the feature values at the corresponding positions of the corresponding channels in the output feature maps of the teacher branch and the student branch.
9. The abnormal object segmentation method based on distillation comparison according to claim 1 or 2, characterized in that: PSPNet with ResNet-50 as the backbone network is used as the semantic segmentation network.
10. The abnormal object segmentation method based on distillation comparison according to claim 6, characterized in that: M=4, C=512.
