Image classification method for improving attention of image target area
Through the two-stage training method and AnnoCAM saliency map generation technology, the problems of instability and poor decision-making interpretability of deep neural network models in real environments are solved, allowing the model to focus on the foreground area, reducing false correlations and improving stability.
Patent Information
- Application Number
- CN202410357669.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-27
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-03-27
AI Technical Summary
Deep neural network models perform erratically in real environments and are difficult to explain their decision-making processes, especially when there are limitations and biases in the training data. The models will learn false correlations and distract attention from unimportant features.
A two-stage training method is adopted, first training the model through cross-entropy loss, then using the AnnoCAM method to generate a saliency map that only focuses on the foreground area, and optimizing the model parameters by explaining the consistency loss to ensure that the model's attention is focused on the most discriminative foreground area. .
It effectively reduces the false correlation of the model, improves the stability of the model in different environments, and generates more accurate saliency maps, so that the model's attention is more focused on the foreground area.
Smart Images

Figure CN118657972A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of explainable artificial intelligence, and in particular to an image classification method for improving the attention of a target area in an image. Background Art
[0002] At present, the performance of deep neural network models in many computer vision tasks has far exceeded the human level, and it can achieve very high performance, but deep neural network models are essentially data-driven artificial intelligence systems. Deep neural network models establish associations between input data and expected results. If the training data and test data meet the independent and identically distributed assumption, that is, the training data and test data are independently sampled from the same distribution, the model can surpass the human level. However, in real situations, due to the limitations and biases in the data collection process, the independent and identically distributed assumption no longer holds, so this data-driven association learning will inevitably learn false contextual associations. If the model deployment environment is always changing, the model will perform poorly when the distribution shifts. In addition, there is no strict theoretical guidance for the design of the deep neural network structure, and the training process uses end-to-end data-driven training, which makes the model inherently unexplainable.
[0003] In recent years, researchers have tried to open the "black box" of deep neural networks through interpretable methods and have proposed many methods for explaining models. Among them, a very widely used type of image classification attribution method is the class activation mapping (CAM), which can highlight the area in the input image that is most relevant to the prediction result, making it easier for people to attribute the prediction result. We used the widely used GradCAM method in this type of method to generate a saliency map and found that the model's decision-making mechanism is not completely consistent with that of humans. Our analysis found that the model's decision-making basis will use image background information, that is, when there are limitations and biases in the training data, identifying a dog may use grass information, etc. In addition, the model's attention is distracted through the saliency map, that is, the model will distract its attention to some unimportant features. Summary of the invention
[0004] To solve the above problems, the present invention provides an image classification method for improving the attention of an image target area, comprising the following steps:
[0005] S1. Obtain a set of images to be classified and their label sets, and preprocess the set of images to be classified to obtain a training set;
[0006] S2. Use the training set and label set to perform the first stage training of the convolutional neural network, and calculate the classification loss through the cross entropy loss function;
[0007] S3. Complete the first stage of training to obtain the initial model, and use the training set to visualize the class features of the initial model to obtain channel semantic vectors under different label types;
[0008] S4. Copy the weights of the initial model as the initial weights of the second model, and perform the second stage training on the second model based on the channel semantic vector and the training set, including:
[0009] S41. Input the sample images in the training set into the second model to the sample image category, and use the cross entropy loss function to calculate the classification loss of the second model;
[0010] S42. Obtaining the first saliency map corresponding to the sample image under the initial model using the AnnoCAM method;
[0011] S43. Obtaining a second saliency map corresponding to the second category image of the sample image using the HiResCAM method;
[0012] S44. Binarize the first saliency map to obtain a binary saliency map, and calculate the explanation consistency loss according to the binary saliency map and the second saliency map;
[0013] S45. Perform a weighted summation of the classification loss and the explanation consistency loss to obtain a training loss, and back-propagate the training loss to optimize the second model parameters;
[0014] S46. Repeat steps S41-S45 until the second model parameters converge;
[0015] S5. Complete the second stage of training to obtain an interpretable convolutional neural network model, which is applied to image classification.
[0016] Beneficial effects of the present invention:
[0017] The present invention visualizes the channel semantics according to the semantic detection function of the convolution kernel, screens the convolution kernel according to the channel semantic visualization result, and labels the convolution kernel into two categories, one is the convolution kernel representing the foreground area, and the other is the convolution kernel representing the background area. When using HiResCAM to generate a saliency map, only the convolution kernel representing the foreground area is used for calculation, thereby effectively generating a saliency map that only represents the foreground area. The present invention calls this method AnnoCAM (Annotation-based Class Activation Map).
[0018] The present invention proposes a two-stage training method. In the first stage, the cross entropy loss is used to train the model. After the model training is completed, the AnnoCAM method is used to generate a saliency map that only focuses on the foreground. Figure 2The value is generated to satisfy the expected properties of the mask to constrain the model interpretation. This paper uses the EPG (Energy-based Pointing Game) and CH (Content Heatmap) indicators to evaluate the method in this paper. The EPG method mainly evaluates the degree to which the model focuses on the foreground area, while the CH method mainly evaluates the degree to which the model focuses on the attention. A large number of experiments have effectively verified that the method proposed in this paper can effectively reduce the false associations of the model and improve the stability of the model deployed in different environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 is a flow chart of the method of the present invention;
[0020] Figure 2 This is a flow chart of the class feature visualization method of the present invention;
[0021] Figure 3 This is a schematic diagram of a visualization example of the characteristics of the present invention;
[0022] Figure 4 This is a schematic diagram of the second stage training of the present invention;
[0023] Figure 5 This is the GradCAM visualization result of the embodiment of the present invention. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] For image classification tasks, the performance of deep neural network models has far surpassed that of humans. However, based on post hoc explanation methods such as GradCAM, we found that the model's decision focus area is not completely consistent with human decision-making. The inconsistency is mainly manifested in:
[0026] (1) The model’s attention is particularly scattered when making decisions. By processing the model’s output image with a post-hoc interpretation method to obtain a saliency map, it can be seen that the saliency map is still highlighted at unimportant features.
[0027] (2) The model may focus on background information when making decisions, such as identifying a dog based on the characteristics of the grass. In most cases, humans mainly identify categories based on the most discriminative object features when identifying objects.
[0028] Although some scholars have proposed methods to integrate prior knowledge into the model training process, the model may still use background information when making decisions; in addition, although the method of adding target boxes or pixel-level calibration can constrain the model to focus on the foreground area, its manual labeling is expensive. In order to better solve the above problems and make the model focus on the most discriminative foreground area, the present invention proposes an image classification method that improves the attention of the target area of the image.
[0029] Specifically, Figure 1 As shown, the specific scheme of this method includes:
[0030] S1. Obtain a set of images to be classified and their label sets, and preprocess the set of images to be classified to obtain a training set.
[0031] Specifically, after obtaining the image set to be classified, the category label of each image is manually annotated, and all labels form a label set; each image to be classified in the image set to be classified is subjected to random cropping transformation and random flipping transformation for image enhancement to obtain an enhanced training set.
[0032] S2. The convolutional neural network is trained in the first stage using the training set and label set, and the classification loss is calculated using the cross entropy loss function.
[0033] Specifically, the sample images in the training set are used as the input of the convolutional neural network, and the sample image categories are output; in the first stage of training in step S2, 90 epochs are trained, the learning rate is reduced by 10 times every 30 epochs, and the initial learning rate is 0.1.
[0034] Specifically, the cross entropy loss function used in step S2 is:
[0035]
[0036] Among them, N represents the number of sample images in the training set, C represents the number of categories in the training set, Indicates whether the i-th sample image belongs to the c-th category. If so, then If not, then f c represents a convolutional neural network, x i represents the i-th sample image, and θ1 represents the trainable parameters of the convolutional neural network (initial model).
[0037] In actual scenarios, the training set data will have limitations and biases, which makes the initial model not only learn the causal correlation features within the target area of the sample image, but also learn the background features that are not causally related to the target features. This makes the initial model unable to perform well in different environments and is unstable. Therefore, it is necessary to conduct a second stage of optimization training based on the initial model. The main purpose of the second stage of optimization training is to add supervisory information to guide the model to learn more target features, so that the optimization model focuses more on the most discriminative foreground area, while reducing the learning of background features.
[0038] S3. Complete the first stage of training to obtain the initial model, and use the training set to visualize the class features of the initial model to obtain channel semantic vectors under different label categories.
[0039] Specifically, through network dissection experiments, it is found that from shallow to deep in the network, the convolution kernels (channels) of different layers have different selectivity for the local content of the picture, and each convolution kernel can be used as a semantic detector for analysis. At the same time, with the increase of the number of network layers, the semantics corresponding to the convolution kernel becomes more and more specific. The deep convolution kernel can detect the concept of specific objects, which is more conducive to human understanding. Therefore, the present invention mainly performs semantic analysis on the last layer of convolutional neural network. Maximum activation response visualization is the simplest convolution kernel semantic visualization method. This method inputs all the pictures of the verification set into the model, and then the convolution kernel generates different activation maps for different input pictures. The input batch pictures are sorted from large to small according to their activation strength, and the activation map with the maximum activation strength and its corresponding input picture are selected. The activation area on the activation map corresponds to the regional features obtained on the input picture to represent the semantics of the convolution kernel.
[0040] For complex data sets, such as ImageNet, in order to make the convolution kernel semantically more consistent, the present invention proposes a class feature visualization method (Class-wise Feature Visualization, CFV). This method uses the training set data of each category to visualize all the convolution kernels in the last layer of the convolutional neural network. If the maximum activation response visualization is used to semantically visualize the convolution kernel, there is a situation where the features of other categories are treated as features of this category. In order to avoid this situation, the present invention uses a gradient-based class activation map as the semantic visualization map of the convolution kernel.
[0041] Specifically, the training set is used to visualize the class features of the initial model to obtain channel semantic vectors under different label categories, including:
[0042] S31. Let the number of label categories be C, and the number of channels of the last convolutional layer of the initial model be M; divide the training set into C subcategory training sets according to the labels.
[0043] S32. Use the sub-category training set corresponding to the c=1, 2, ..., C label categories to visualize the class features of the initial model, and obtain the channel semantic vector of the initial model under the cth label category, such as Figure 2 As shown, including:
[0044] S321. Input the i=1, 2, ..., n sample images in the subcategory training set corresponding to the c-th label category into the initial model, extract the feature image output by the last convolutional layer of the convolutional neural network; perform gradient-based class activation mapping on the feature image to obtain the semantic visibility graph of each channel of the feature image in the last convolutional layer of the initial model; n represents the number of sample images in the subcategory training set;
[0045] S322. Repeat step S321 until all sample images in the training set corresponding to the c-th label category complete the gradient-based class activation mapping, so that each channel in the last convolutional layer of the initial model corresponds to n semantic visible graphs;
[0046] Specifically, a gradient-based class activation mapping is performed on the feature image to obtain the semantic visibility graph of each channel of the feature image in the last convolutional layer of the initial model, which is expressed as:
[0047]
[0048] in, A represents the semantic visualization of the feature image belonging to the cth label category in the mth channel, m represents the activation map of the mth channel in the last convolutional layer of the initial model, It represents the calculation gradient of the activation map of the mth channel under the cth label category, and ReLU represents the activation function.
[0049] S323. For each channel in the last convolutional layer of the initial model, select the semantic visibility map with the maximum activation value from all its semantic visibility maps as its own channel semantic heat map;
[0050] S324. Each channel in the last convolutional layer of the initial model is semantically annotated according to its own channel semantic heat map, and all channel semantic annotation results are arranged and combined in the order of their corresponding channels to obtain the channel semantic vector.
[0051] Specifically, in step S324, any channel performs channel semantic annotation according to its own channel semantic heat map, including: extracting the highlighted area in the channel semantic heat map, if the highlighted area is located in the target area, the channel semantic annotation of the channel is 1; if the highlighted area is located in the background area, the channel semantic annotation of the channel is 0. The present invention uses manual annotation to perform channel semantic annotation. In order to reduce the workload of manual annotation, all channels are arranged in descending order according to the activation values of the channel semantic heat map, and only the first 10 or 20 channels are selected for manual annotation, and the remaining channels with small intensity are defaulted to be labeled with a channel semantic annotation of 1.
[0052] Specifically, Figure 3 As shown in the figure, this paper visualizes the class features of the ResNet50 pre-trained model. Figure (a) visualizes the channel semantic heat map corresponding to the sandbag class. It can be clearly observed that the highlighted areas corresponding to the channel semantic heat maps in the 1st, 2nd, 3rd, and 4th rows are located in the target area (foreground area), that is, the convolution kernel represents the foreground features of the sandbag, while the convolution kernels in the 5th and 6th rows correspond to the glove semantics and no longer belong to the foreground area. In Figure (b), the highlighted areas corresponding to the channel semantic heat maps in the 1st, 2nd, and 6th rows are located in the target area, and the highlighted areas corresponding to the channel semantic heat maps in the 3rd, 4th, and 5th rows are located in the background area. Therefore, based on the class feature visualization analysis, it can be found that the model has not only learned the foreground features from the training data, but also the background information. At the same time, it is possible to manually and simply annotate the semantics of each convolution kernel as to whether it belongs to the foreground feature or the background feature. The channel semantic vector is formed by channel semantic annotation, thereby Figure 3 In the figure, the channel semantic vector corresponding to (a) is [1,1,1,1,0,0], and the channel semantic vector corresponding to (b) is [1,1,0,0,0,1].
[0053] S4. Based on the channel semantic vector and training set, the initial model is trained in the second stage, such as Figure 4 As shown, including:
[0054] S41. Copy the initial model weights as the initial weights of the second model, input the sample images in the training set into the initial model and the second model respectively, and calculate the classification loss of the second model using the cross entropy loss function;
[0055] S42. The HiResCAM method is used to obtain the saliency map corresponding to the sample image under the second model, which is called the second saliency map and is expressed as:
[0056]
[0057] The HiResCAM method considers the activation maps of all channels, so the convolution kernels representing background information may be used to calculate the saliency map. Of course, in order to faithfully reflect the model decision mechanism, all convolution kernels should be considered. However, in order to improve the localization ability of the saliency map, the convolution kernels representing background information will hinder the localization ability of the saliency map. Therefore, the convolution kernels can be manually screened, and the convolution kernels that only represent the semantic information of the foreground area are retained, and the convolution kernels with background semantic information are discarded, thereby improving the localization ability of the saliency map.
[0058] S43. Using the AnnoCAM method to obtain a salient image corresponding to the sample image under the initial model, which is called the first salient image;
[0059] Specifically, step S43 uses the AnnoCAM method to obtain the first saliency map corresponding to the sample image under the initial model, including:
[0060] S431. Input a sample image in the training set into the initial model to obtain the corresponding sample image category;
[0061] S432. The sample image and its sample image category are interpreted and visualized using the AnnoCAM method to obtain a first saliency map, which is expressed as:
[0062]
[0063] in, represents the first saliency map of the sample image belonging to the cth label category, F represents, A m represents the activation map of the mth channel in the last convolutional layer of the initial model, It indicates that the gradient of the activation map of the mth channel is calculated under the cth label category, ReLU indicates the activation function, and ⊙ indicates that the two matrices are multiplied by the corresponding position elements. Represents the channel semantic annotation of the mth channel in the last convolutional layer of the initial model under the cth label category.
[0064] S44. Binarize the first saliency map to obtain a binary saliency map, and calculate the explanation consistency loss according to the binary saliency map and the second saliency map;
[0065] Specifically, the AnnoCAM method proposed in the present invention will reduce the attention of the background area, but not all features in the foreground area are discriminant features. Therefore, a thresholding operation can be used to discard unimportant features by thresholding the first saliency map, thereby improving the positioning ability of the first saliency map, which is expressed as:
[0066]
[0067] in, represents the enhanced salient image obtained by thresholding the first salient map belonging to the cth label category, τ represents the threshold, and T() represents the thresholding operation, which is specifically:
[0068]
[0069] The first saliency map The pixel value of the jth pixel in .
[0070] The enhanced saliency map generated by thresholding the first saliency map has significantly improved positioning ability, but the enhanced saliency map is not faithful to the decision-making process of the model. The purpose of the present invention is to make the decision area of the model as consistent as possible with the saliency map area, so that the actual decision of the model also meets the expected property that "the highlight area is located in the most discriminative target area in the image". Energy loss can produce the best EPG score, and energy-based loss can suppress background features and pay more attention to foreground features. Therefore, using energy loss to guide model interpretation can produce the best effect. Energy loss needs to provide a binarized Ground Truth mask. Therefore, this paper uses the binarization saliency map operation to obtain the Ground Truth mask. It only needs to set a threshold to binarize the first saliency map generated by AnnoCAM. Its formal expression is as follows:
[0071]
[0072] in, represents the binary saliency map obtained by binarizing the first saliency map belonging to the cth label category, τ represents the threshold, and I() represents the binarization operation, which is specifically:
[0073]
[0074] The first saliency map The pixel value of the jth pixel in .
[0075] Both the thresholded first saliency map and the binarized first saliency map need to set a threshold value τ, and the main difference is in two aspects. First, the thresholded first saliency map takes values between 0 and 1, while the binarized first saliency map takes values of 0 or 1. Second, the thresholded first saliency map is used to improve the saliency map positioning ability, and its main purpose is to verify that more focused attention helps to reduce the degree of false association of the model, while the main purpose of the binarized first saliency map is to generate a mask, which is used as the explanation Ground Truth for the second stage training of the model. The reason for not using the thresholded first saliency map as the explanation Ground Truth for model training is that the purpose of the model optimization of the present invention only requires that the explanation of the second stage model is within a certain range of the target area, and does not require that the saliency map pattern in the second stage model area is also consistent with the saliency map area pattern generated by AnnoCAM in the first stage, so that the model can learn adaptively within the area and improve the accuracy of the model.
[0076] S45. Perform a weighted summation of the classification loss and the explanation consistency loss to obtain a training loss, and back-propagate the training loss to optimize the second model parameters;
[0077] S46. Repeat steps S41-S45 until the second model parameters converge.
[0078] Specifically, the calculation formula for explaining the consistency loss is:
[0079]
[0080] in, represents the second saliency map obtained using the HiResCAM method, represents the binary saliency map after the first saliency map obtained by the binarized AnnoCAM method, x i represents the i-th sample image, represents the initial model, Represents the second model, and N represents the number of sample images in the training set.
[0081] The training loss is obtained by weighted summing of the classification loss and the explanation consistency loss, expressed as:
[0082] L=L CE +λL AEC
[0083] Among them, L CE represents the classification loss, L ECC represents the explanation consistency loss, and λ represents a hyperparameter.
[0084] S5. Complete the second stage of training to obtain an interpretable convolutional neural network model, which is applied to image classification.
[0085] In one embodiment, the present invention conducts various experiments to verify the effectiveness of the method proposed in the present invention. First, the localization ability of the saliency map generated by AnnoCAM and HiResCAM under different thresholds is verified. Then, the effectiveness of the method of the present invention is verified on ImageNet. Then, the selection of the hyperparameter λ between the cross entropy loss and the energy-based class activation map consistency loss is verified by ablation experiments. Finally, the effectiveness of the method is qualitatively evaluated by the post-interpretation method GradCAM.
[0086] The present invention uses the PyTorch framework to carry out all experiments. For the second stage of model training, the present invention is optimized based on the Py-Torch official pre-trained model, and mainly uses ResNet18 and ResNet50 to carry out experiments. The present invention uses the SGD stochastic gradient descent algorithm to optimize the model, and its initial learning rate is set to 0.1, and then the learning rate decays by 0.1 times after every 30 epochs. The operating environment of the model is shown in Table 1.
[0087] Table 1 Experimental environment configuration
[0088]
[0089] Preferably, in order to verify whether the AnnoCAM method can generate a saliency map that meets the expected properties, the present invention uses the EPG index to verify whether the saliency map generated by the method focuses on the foreground area, wherein the larger the EPG value, the more the saliency map generated by the method focuses on the foreground information.
[0090] The present invention evaluates the AnnoCAM method at different thresholds on the ResNet18 and ResNet50 pre-trained models. Table 2 shows the effectiveness of the AnnoCAM method. As the threshold increases, the saliency map becomes more focused and the positioning capability becomes stronger. At the same time, the present invention also evaluates the HiResCAM method at different thresholds on the ResNet18 and ResNet50 pre-trained models. Table 2 shows that as the threshold increases, the HiResCAM positioning capability is significantly improved, but not as much as the AnnoCAM method. This also shows that background information can be effectively removed by semantically labeling the convolution kernel.
[0091] Table 2 Evaluation of the localization ability of the interpretation methods under different thresholds τ
[0092]
[0093] Preferably, the two-stage training method proposed in the present invention is called AEC (Annotaion-based Explanation Consistency). In order to verify the effectiveness of the AEC method, the present invention directly performs secondary training on the ResNet18 and ResNet50 pre-trained models. As can be seen from Table 3, the model trained by the present invention performs best in the EPG index with a small loss of accuracy. This experiment shows that the method can effectively improve the causal decision-making ability of the model by adding a small amount of supervisory information and allowing the model to focus on more discriminative areas. As can be seen from Table 3, although the method of the present invention is slightly lower than the CGC method in the CH index, the method of the present invention is slightly higher than the CGC method in the IAUC index, which shows that the explanation generated by the model trained by the method of the present invention (AEC) using the HiResCAM method is more faithful to the model.
[0094] Table 3 Evaluation results on ImageNet
[0095]
[0096] Table 4 Evaluation results of HiResCAM explanation based on ResNet50 using IAUC metric
[0097]
[0098] Preferably, the model training process of the method of the present invention is divided into two stages. For the first stage, the model training is optimized only based on the cross entropy loss. Due to the limitations and biases of the data, the model will inevitably learn false correlation features. Therefore, in the second stage, an explanation constraint is added to guide the model to focus only on the foreground area features, and at the same time limit the distribution of the model explanation in the target feature area, so that the model attention is more focused. The greater the proportion of the explanation constraint, the more the model attention is focused on the mask area obtained by the binary AnnoCAM method to generate the saliency map, that is, more attention is paid to the most discriminative foreground area, but it may lead to a decrease in accuracy, because in the ImageNet data set, some pictures have unclear foreground features, and it is difficult to judge their categories without relying on background features. The smaller the trade-off parameter λ of the explanation constraint, the better the accuracy can be achieved by using a wider range of features in the picture. According to the results in Table 5, this paper selects hyperparameter values with relatively good accuracy and EPG values, λ=0.5, τ=0.6.
[0099] Table 6 Ablation experiment
[0100]
[0101]
[0102] Preferably, in order to verify whether the AEC method proposed in the present invention focuses on the most discriminative foreground area, this section uses the GradCAM interpretation method to visualize the decision basis of the model trained by the baseline ERM, CGC and AEC methods. Figure 5 As shown, the second row corresponds to the saliency map of the baseline method ERM. It can be found that the model's attention is scattered, and the model uses background information for decision-making. For the CGC method, corresponding to the third row in the figure, the model's saliency map is more concentrated, and the focus on background information is reduced, but background information is still used when making decisions. For example, for can openers, the model makes decisions more based on can features. For the AEC method proposed in the present invention, it effectively reduces the focus on background information, and the attention is also more concentrated. For example, for seat belts, bicycles, and sandbags, it no longer pays attention to background information like the CGC method.
[0103] In the present invention, unless otherwise clearly stipulated and limited, the terms such as "installation", "setting", "connection", "fixation" and "rotation" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral one; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium; it can be the internal connection of two elements or the interaction relationship between two elements. Unless otherwise clearly defined, ordinary technicians in this field can understand the specific meanings of the above terms in the present invention according to the specific circumstances.
[0104] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. An image classification method for improving the attention of an image target area, characterized in that: The following steps are involved: S1. Obtain a set of images to be classified and their label sets, and preprocess the set of images to be classified to obtain a training set; S2. Use the training set and label set to perform the first stage training of the convolutional neural network, and calculate the classification loss through the cross entropy loss function; S3. Complete the first stage of training to obtain the initial model, and use the training set to visualize the class features of the initial model to obtain channel semantic vectors under different label categories; S4. Copy the weights of the initial model as the initial weights of the second model, and perform the second stage training on the second model based on the channel semantic vector and the training set, including: S41. Input the sample images in the training set into the second model to obtain the sample image category, and use the cross entropy loss function to calculate the classification loss of the second model; S42. Calculate the first saliency map corresponding to the sample image under the initial model using the AnnoCAM method; S43. Calculate the second saliency map corresponding to the sample image under the second model using the HiResCAM method; S44. Binarize the first saliency map to obtain a binary saliency map, and calculate the explanation consistency loss according to the binary saliency map and the second saliency map; S45. Perform a weighted summation of the classification loss and the explanation consistency loss to obtain a training loss, and back-propagate the training loss to optimize the second model parameters; S46. Repeat steps S41-S45 until the second model parameters converge; S5. Complete the second stage of training to obtain an interpretable convolutional neural network model, which is applied to image classification.
2. The image classification method for improving the attention of the target area of the image according to claim 1, characterized in that: The sample images in the training set are used as the input of the convolutional neural network, and the sample image categories are output; in the first stage of training in step S2, 90 epochs are trained, the learning rate is reduced by 10 times every 30 epochs, and the initial learning rate is 0.
1.
3. The image classification method for improving the attention of the target area of the image according to claim 1, characterized in that: The cross entropy loss function used in step S2 is: Among them, N represents the number of sample images in the training set, C represents the number of categories in the training set, Indicates whether the i-th sample image belongs to the c-th category. If so, then If not, then f c Represents the convolutional neural network output score for the cth category, x i represents the i-th sample image, and θ1 represents the trainable parameters of the initial model convolutional neural network.
4. The image classification method for improving the attention of the target area of an image according to claim 1, characterized in that: The training set is used to visualize the class features of the initial model to obtain channel semantic vectors under different label types, including: S31. Let the number of label categories be C, and the number of channels of the last convolutional layer of the initial model be M; divide the training set into C subcategory training sets according to the labels; S32. Use the sub-category training set corresponding to the c=1, 2, ..., C label categories to visualize the class features of the initial model, and obtain the channel semantic vector of the initial model under the c-th label category, including: S321. Input the i=1, 2, ..., n sample images in the subcategory training set corresponding to the c-th label category into the initial model, extract the feature image output by the last convolutional layer of the convolutional neural network; perform gradient-based class activation mapping on the feature image to obtain the semantic visibility graph of each channel of the feature image in the last convolutional layer of the initial model; n represents the number of sample images in the subcategory training set; S322. Repeat step S321 until all sample images in the training set corresponding to the c-th label category complete the gradient-based class activation mapping, so that each channel in the last convolutional layer of the initial model corresponds to n semantic visible graphs; S323. For each channel in the last convolutional layer of the initial model, select the semantic visibility map with the maximum activation value from all its semantic visibility maps as its own channel semantic heat map; S324. Each channel in the last convolutional layer of the initial model is semantically annotated according to its own channel semantic heat map, and all channel semantic annotation results are arranged and combined in the order of their corresponding channels to obtain the channel semantic vector.
5. The image classification method for improving the attention of the target area of the image according to claim 4, characterized in that: Perform gradient-based class activation mapping on the feature image to obtain the semantic visibility graph of each channel of the feature image in the last convolutional layer of the initial model, expressed as: in, A represents the semantic visualization of the feature image belonging to the cth label category in the mth channel, m represents the activation map of the mth channel in the last convolutional layer of the initial model, It represents the calculation gradient of the activation map of the mth channel under the cth label category, and ReLU represents the activation function.
6. The image classification method for improving the attention of the target area of the image according to claim 4, characterized in that: In step S324, any channel performs channel semantic annotation according to its own channel semantic heat map, including: extracting the highlighted area in the channel semantic heat map, if the highlighted area is located in the target area, the channel semantic annotation of the channel is 1; if the highlighted area is located in the background area, the channel semantic annotation of the channel is 0.
7. The image classification method for improving the attention of the target area of an image according to claim 1, characterized in that: Step S42 uses the AnnoCAM method to obtain an enhanced salient image corresponding to the first predicted category of the image, including: S421. Input a sample image in the training set into the initial model to obtain the corresponding sample image category; S422. The sample image and its sample image category are interpreted and visualized using the AnnoCAM method to obtain a first saliency map, which is expressed as: in, A represents the first saliency map of the sample image belonging to the cth label category. m represents the activation map of the mth channel in the last convolutional layer of the initial model, It indicates that the gradient of the activation map of the mth channel is calculated under the cth label category, ReLU indicates the activation function, ⊙ indicates the multiplication of the elements at the corresponding positions of the two matrices, Represents the channel semantic annotation of the mth channel in the last convolutional layer of the initial model under the cth label category.
8. The image classification method for improving the attention of the target area of an image according to claim 1, characterized in that: The calculation formula for explaining consistency loss is: in, represents the second saliency map obtained using the HiResCAM method, represents a binary saliency map, x i represents the i-th sample image, represents the initial model, represents the second model, and N represents the number of sample images in the training set; The training loss is obtained by weighted summing of the classification loss and the explanation consistency loss, expressed as: L=L CE +λL AEC Among them, L CE represents the classification loss, L AEC represents the explanation consistency loss, and λ represents a hyperparameter.
Citation Information
Patent Citations
Multi-expert fusion chest X-ray image auxiliary diagnosis system and method
CN117437207A
Weak supervision semantic segmentation method and device and storage medium
CN117496136A
General target detection method for adaptive attention guidance mechanism
WO2021139069A1
Cited By
Deep sea scene-oriented sonar point cloud semantic understanding deep learning network modulation method
CN119538073A
