Model output fusion method and device, storage medium and electronic equipment
By determining the pixel point contribution degree and calculating the fusion weight in the model output fusion method, the problem of poor performance of the model in the prior art on unknown data is solved, and the generalization ability and reliability of the model are improved.
Patent Information
- Application Number
- CN202411706802.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-04-11
AI Technical Summary
Existing model output fusion methods perform poorly on unknown data, resulting in poor generalization and reliability of the integration model.
By determining the contribution of multiple pixel points in the target image to the classification results of the basic classification model, determining the number of pixel points in the target area, and calculating the fusion weight of the basic classification model based on the number of pixel points in the intersection, and finally weighted fusion of the classification results is performed.
It improves the performance of the model on unknown data, enhances the generalization ability and reliability of the model, and makes the final classification results more interpretable.
Smart Images

Figure CN119810499A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a model output fusion method, device, storage medium and electronic device. Background Art
[0002] At present, the integrated model that integrates multiple basic models can combine the advantages of multiple basic models by relying on the model output fusion method, and quickly improve the performance of the final model in a short time. The key to the model output fusion method lies in the setting of weights, which are usually determined according to the performance ranking of the basic models. The higher the ranking of the basic model, the greater the weight.
[0003] However, the performance ranking of the model is obtained on the existing data set, and may not have the same performance on unknown data, resulting in the integrated model not having good generalization ability; at the same time, the existing ranking weighted method uses the same weight for all input data to weight the prediction results of the basic model, which cannot specifically bring into play the advantages of each basic model, resulting in poor reliability of the final model. Summary of the invention
[0004] The present invention provides a model output fusion method, device, storage medium and electronic device to solve the problems of poor generalization ability and reliability of the current model output fusion method.
[0005] In order to solve the above problems, the present invention adopts the following technical solutions:
[0006] In a first aspect, an embodiment of the present invention provides a model output fusion method, the method comprising:
[0007] For any basic classification model among a plurality of basic classification models, determining contribution of a plurality of first pixel points in a target image to a classification result of the basic classification model; the target image is a model input of the plurality of basic classification models;
[0008] Determine the target quantity of a plurality of second pixel points in the target area in the target image;
[0009] Determine a plurality of third pixel points with the highest contribution among the plurality of first pixel points; the number of the plurality of third pixel points is the target number;
[0010] Determine an intersection of the plurality of third pixel points and the plurality of second pixel points, and determine a fusion weight of the basic classification model based on the number of pixel points in the intersection;
[0011] Based on the fusion weights corresponding to the multiple basic classification models, the classification results corresponding to the multiple basic classification models are fused to obtain a final classification result for the target image.
[0012] In one embodiment of the present invention, determining the contribution of a plurality of first pixels in the target image to the classification result of the basic classification model includes:
[0013] The basic classification model and the target image are input into a preset interpretability model to obtain an attribution map output by the interpretability model; the attribution map represents the contribution of multiple first pixel points in the target image to the classification result of the basic classification model.
[0014] In one embodiment of the present invention, the interpretability model is a first interpretability model, and the first interpretability model is used to perform the following steps:
[0015] Input the target image into the basic classification model to obtain the feature map and classification result of the last convolutional layer of the basic classification model;
[0016] Back-propagating the classification result to determine the gradient corresponding to the feature map;
[0017] Determining the weight of each channel of the feature map based on the global average value of the gradient;
[0018] The feature maps are weighted summed based on the weights to generate the attribution map.
[0019] In one embodiment of the present invention, the interpretability model is a second interpretability model, and the second interpretability model is used to perform the following steps:
[0020] Input the target image into the basic classification model, and obtain multiple channels and first classification scores of the activation map of the last convolutional layer of the basic classification model;
[0021] Applying multiple channels of the activation map as masks to the target image respectively to generate multiple second images; inputting the multiple second images into the basic classification model respectively to obtain multiple second classification scores;
[0022] Based on the first classification score and the plurality of second classification scores, a plurality of score differences are obtained; and based on the plurality of score differences, weights corresponding to the plurality of channels of the activation map are determined;
[0023] The attribution map is generated based on the multiple channels of the activation map and the weights corresponding to the multiple channels of the activation map.
[0024] In one embodiment of the present invention, determining the target number of a plurality of second pixel points in the target area in the target image includes:
[0025] The target image is input into a pre-trained semantic segmentation model, a mask of the target area in the target image is output, and the number of targets of multiple second pixel points in the mask is determined.
[0026] In one embodiment of the present invention, determining the fusion weight of the basic classification model based on the number of pixels in the intersection includes:
[0027] Determine the total number of pixels of the intersection of the multiple basic classification models;
[0028] For any basic classification model, the fusion weight of the basic classification model is determined based on the ratio between the number of pixel points in the intersection of the basic classification model and the total number of pixel points.
[0029] In one embodiment of the present invention, based on the fusion weights corresponding to the multiple basic classification models, the classification results corresponding to the multiple basic classification models are fused to obtain a final classification result for the target image, including:
[0030] For any basic classification model, based on the classification result and fusion weight corresponding to the basic classification model, determine the weighted classification result corresponding to the basic classification model;
[0031] Based on the weighted classification results corresponding to each of the multiple basic classification models, a final classification result for the target image is determined.
[0032] In a second aspect, based on the same inventive concept, an embodiment of the present invention provides a model output fusion device, the device comprising:
[0033] A contribution determination module, used to determine the contribution of multiple first pixel points in a target image to a classification result of any one of multiple basic classification models; the target image is a model input of the multiple basic classification models;
[0034] A quantity determination module, used to determine the target quantity of a plurality of second pixel points in the target area in the target image;
[0035] A pixel point determination module, used to determine a plurality of third pixel points with a higher contribution degree among the plurality of first pixel points; the number of the plurality of third pixel points is greater than or equal to the target number;
[0036] A weight determination module, used to determine the intersection of the plurality of third pixel points and the plurality of second pixel points, and determine the fusion weight of the basic classification model based on the number of pixel points in the intersection;
[0037] The fusion processing module is used to perform fusion processing on the classification results corresponding to each of the multiple basic classification models based on the fusion weights corresponding to each of the multiple basic classification models, so as to obtain a final classification result for the target image.
[0038] In one embodiment of the present invention, the contribution determination module includes:
[0039] The attribution map generation submodule is used to input the basic classification model and the target image into a preset interpretability model to obtain the attribution map output by the interpretability model; the attribution map represents the contribution of multiple first pixel points in the target image to the classification result of the basic classification model.
[0040] In one embodiment of the present invention, the interpretability model is a first interpretability model, and the attribution graph generation submodule includes:
[0041] A first input unit, used to input the target image into the basic classification model, and obtain a feature map and classification result of the last convolutional layer of the basic classification model;
[0042] A gradient determination unit, used to perform back propagation on the classification result to determine the gradient corresponding to the feature map;
[0043] A first weight determination unit, configured to determine a weight of each channel of the feature map based on a global average value of the gradient;
[0044] The first attribution graph generating unit is used to perform weighted summation on the feature graph based on the weight to generate the attribution graph.
[0045] In one embodiment of the present invention, the interpretability model is a second interpretability model, and the attribution graph generation submodule includes:
[0046] A second input unit, used to input the target image into the basic classification model, and obtain multiple channels and a first classification score of an activation map of a last convolutional layer of the basic classification model;
[0047] a score determination unit, configured to apply the multiple channels of the activation map as masks to the target image respectively to generate multiple second images; and input the multiple second images into the basic classification model respectively to obtain multiple second classification scores;
[0048] A second weight determination unit is configured to obtain a plurality of score differences based on the first classification score and the plurality of second classification scores; and determine weights corresponding to the plurality of channels of the activation map based on the plurality of score differences;
[0049] The second attribution map generating unit is used to generate the attribution map based on the multiple channels of the activation map and the weights corresponding to the multiple channels of the activation map.
[0050] In one embodiment of the present invention, the quantity determination module includes:
[0051] The semantic segmentation submodule is used to input the target image into a pre-trained semantic segmentation model, output a mask of the target area in the target image, and determine the target number of multiple second pixel points in the mask.
[0052] In one embodiment of the present invention, the weight determination module includes:
[0053] A total number determination submodule, used to determine the total number of pixel points of the intersection of the multiple basic classification models;
[0054] The weight determination submodule is used to determine the fusion weight of any basic classification model based on the ratio between the number of pixel points in the intersection of the basic classification model and the total number of pixel points.
[0055] In one embodiment of the present invention, the fusion processing module includes:
[0056] A weighting submodule, for determining, for any basic classification model, a weighted classification result corresponding to the basic classification model based on the classification result corresponding to the basic classification model and a fusion weight;
[0057] The fusion submodule is used to determine the final classification result for the target image based on the weighted classification results corresponding to each of the multiple basic classification models.
[0058] In the third aspect, based on the same inventive concept, an embodiment of the present invention provides a computer-readable storage medium having an executable program stored thereon, which, when executed by a processor, implements the model output fusion method proposed in the first aspect of the present invention.
[0059] In a fourth aspect, based on the same inventive concept, an embodiment of the present invention provides an electronic device, including:
[0060] A memory for storing an executable program;
[0061] processor;
[0062] When the executable program is executed by the processor, the model output fusion method proposed in the first aspect of the present invention is implemented.
[0063] Compared with the prior art, the present invention has the following advantages:
[0064] A model output fusion method provided by an embodiment of the present invention first determines the contribution of multiple first pixels in a target image to the classification result of a basic classification model for any of multiple basic classification models; then determines the number of targets of multiple second pixels in a target area in the target image, and determines a third pixel with a higher contribution among multiple first pixels; then determines the intersection of multiple third pixels and multiple second pixels, and determines the fusion weight of the basic classification model based on the number of pixels in the intersection; finally, based on the fusion weights corresponding to each of the multiple basic classification models, the classification results corresponding to each of the multiple basic classification models are fused to obtain the final classification result for the target image. The embodiment of the present invention can effectively reflect the correctness of the area concerned by the basic model by determining the intersection of multiple third pixels with higher contribution and multiple second pixels in the target area, and then assigns different fusion weights to the classification results of each basic model according to the size of the intersection, so that the final classification result of the target image can be more interpretable, and has higher reliability and better generalization ability than the method of setting weights according to the performance of the basic model on the existing data set. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0066] Figure 1 It is a flowchart of the steps of a model output fusion method in one embodiment of the present invention.
[0067] Figure 2 It is a flowchart of a model output fusion method in one embodiment of the present invention.
[0068] Figure 3 It is a schematic diagram of functional modules of a model output fusion device in one embodiment of the present invention.
[0069] Figure 4 It is a schematic structural diagram of an electronic device in one embodiment of the present invention. DETAILED DESCRIPTION
[0070] 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.
[0071] It should be noted that the current model output fusion methods usually use voting, averaging and other methods. Among them, the voting method includes weighted voting, and the averaging method includes weighted averaging. The key lies in the setting of weights, which are usually determined according to the performance ranking of the basic model. The higher the ranking of the basic model, the greater the weight. This method has the following main disadvantages:
[0072] 1. Different basic models may be good at predicting different data, but the existing ranking weighting method uses the same weight for all input data to weight the prediction results of the basic model, which is unable to give full play to the advantages of each basic model in a targeted manner.
[0073] 2. The performance ranking of the basic model is obtained on the existing data set, and it may not have the same performance on unknown data. The integrated model does not have good generalization ability.
[0074] 3. The weights are determined only based on the model performance without considering the causal relationship within the model, resulting in a poor model reliability.
[0075] In view of the poor generalization ability and reliability of the current model output fusion method, the present invention aims to provide a model output fusion method, firstly, for any basic classification model among multiple basic classification models, determine the contribution of multiple first pixels in the target image to the classification result of the basic classification model; then determine the target number of multiple second pixels in the target area of the target image, and determine the third pixel with the highest contribution among the multiple first pixels; then by determining the intersection of multiple third pixels and multiple second pixels, the fusion weight of the basic classification model can be determined based on the number of pixels in the intersection; finally, based on the fusion weights corresponding to the multiple basic classification models, the classification results corresponding to the multiple basic classification models are fused to obtain the final classification result for the target image. In this way, by determining the intersection of multiple third pixels with the highest contribution and multiple second pixels in the target area, the correctness of the area concerned by the basic model can be effectively reflected, and then different fusion weights are assigned to the classification results of each basic model according to the size of the intersection, so that the final classification result of the target image can be made more interpretable, and compared with the method of setting weights according to the performance of the basic model on the existing data set, it has higher reliability and better generalization ability.
[0076] Reference Figure 1 , showing a model output fusion method of the present invention, the method may include the following steps:
[0077] S101: For any basic classification model among multiple basic classification models, determine the contribution of multiple first pixel points in a target image to a classification result of the basic classification model.
[0078] In this embodiment, the target image is the model input of multiple basic classification models. That is, by inputting the target image into multiple basic classification models respectively, each basic classification model outputs a classification result for the target image. The classification result can be used to indicate the confidence of one or more target objects in the target image. Among them, the target image can be a new image different from the existing data set.
[0079] For example, when the target object to be identified is a bird, by inputting the target image into multiple basic classification models, each basic classification model can output the confidence of the target bird in the target image. Different basic classification models can output different classification results, that is, different confidences can be output for the same target bird.
[0080] It should be noted that the multiple basic classification models are used to identify one or more target objects in the target image, and the multiple basic classification models can be trained using the same or different training sets.
[0081] In this embodiment, considering that different basic classification models may focus on different image areas when making predictions, by identifying the contribution of multiple first pixel points in the target image to the classification results of the basic classification model, it is possible to effectively reflect the image area that the basic classification model focuses on when making predictions, and then according to the size of the contribution, the decision basis and decision process of the basic classification model can be effectively understood, thereby improving the interpretability of the basic classification model. Among them, multiple first pixel points represent all the pixel points that constitute the target image.
[0082] It should be noted that the image area that a reliable basic classification model focuses on when making a decision should focus on the target itself. In other words, the more the multiple first pixel points that the basic classification model focuses on are concentrated in the area where the target itself is located, the more reliable the classification result of the basic classification model will be.
[0083] Exemplarily, if the target object to be identified is located in area A in the target image, and multiple first pixel points in area A together constitute the target object, and at the same time, the area detected to have a higher contribution to the classification result of the basic classification model is area B, then the more first pixel points that overlap between area A and area B, the higher the accuracy of the basic classification model's focus area, and the more reliable the model's decision.
[0084] S102: Determine the target number of a plurality of second pixel points in the target area in the target image.
[0085] In this embodiment, the target area refers to the area where the target object to be identified is located in the target image. Specifically, the target area may be the foreground of the target image, and the foreground may include one or more target objects to be identified.
[0086] In a specific implementation, in order to achieve comprehensive and accurate recognition of the target area, the target image can be input into a pre-trained semantic segmentation model, and a mask of the target area in the target image can be output, and the number of targets of multiple second pixel points in the mask can be determined.
[0087] It should be noted that the mask of the target area refers to a binary or multi-class image of a specific area selected or filtered from the target image. The mask can be single-channel, such as a grayscale image, with a value of 0 or 1, which is used to indicate whether a pixel is selected; it can also be multi-channel, used to distinguish different categories, for example, a pixel value of 1 can represent a "person", a pixel value of 2 can represent a "car", and so on.
[0088] In this embodiment, the semantic segmentation model can be a general model, the recognition targets of which include at least the recognition targets of multiple basic classification models; the semantic segmentation model can also be trained based on the training sets of multiple basic classification models, that is, the semantic segmentation model is used to recognize the recognition targets of multiple basic classification models.
[0089] In this embodiment, by extracting the mask of the target area in the target image, the number of targets of multiple second pixel points in the mask can be counted, wherein the multiple second pixel points in the mask are the pixel points that the basic classification model needs to pay attention to when performing target recognition. The more second pixel points the basic classification model pays attention to when making decisions, the higher the accuracy of the model's focus area, and the more reliable the model's decision.
[0090] S103: Determine a plurality of third pixel points with higher contribution among the plurality of first pixel points.
[0091] In this embodiment, the number of the third pixels is the target number. Exemplarily, if the target number of the second pixels in the mask is k, the k third pixels with the highest contribution will be determined from the first pixels.
[0092] In this embodiment, by extracting the same number of pixels as the second pixels in the mask from all the first pixels of the target image, it is possible to effectively determine whether the pixels focused on by the basic classification model are concentrated in the extracted multiple third pixels.
[0093] S104: Determine an intersection of the plurality of third pixel points and the plurality of second pixel points, and determine a fusion weight of a basic classification model based on the number of pixel points in the intersection.
[0094] In this implementation, by calculating the intersection of a third pixel point and a plurality of second pixel points, the accuracy of the area concerned by the basic classification model can be accurately reflected.
[0095] It should be noted that the number of pixels in the intersection reflects the size of the intersection. The larger the intersection, the higher the overlap between the third pixels and the second pixels. When the third pixels completely overlap with the second pixels, the intersection is the largest, indicating that the pixels focused on by the basic classification model all belong to the area where the target object to be identified is located.
[0096] In this implementation, different basic classification models may correspond to different intersections, and different fusion weights may be assigned to the multiple basic classification models according to the size of the intersections.
[0097] In the specific implementation, the intersection of the basic classification models can be expressed as:
[0098] I={a1,a2,…,a n} (1);
[0099] Among them, I represents the intersection of the basic classification models, {a1, a2, …, a n} represents the pixel point in the intersection.
[0100] In this embodiment, after the intersection of each basic classification model is obtained by statistics, the fusion weight of each basic classification model can be determined by normalization. In a specific implementation, the total number of pixels in the intersection of multiple basic classification models can be first determined; then, for any basic classification model, the fusion weight of the basic classification model can be determined based on the ratio between the number of pixels in the intersection of the basic classification model and the total number of pixels.
[0101] Specifically, the fusion weights of each basic classification model can be calculated using the following formula:
[0102]
[0103] Among them, j represents the index of the jth basic classification model, ω j represents the fusion weight of the jth basic classification model, I j represents the number of pixels in the intersection of the jth basic classification model; ∑I represents the total number of pixels in the intersection of all basic classification models.
[0104] S105: Based on the fusion weights corresponding to the multiple basic classification models, the classification results corresponding to the multiple basic classification models are fused to obtain a final classification result for the target image.
[0105] In the specific implementation, after calculating the fusion weight of any basic classification model, the weighted classification result corresponding to the basic classification model can be obtained according to the classification result and fusion weight corresponding to the basic classification model; and then the weighted classification results corresponding to multiple basic classification models are combined to determine the final classification result for the target image.
[0106] Specifically, the final classification results of multiple basic classification models for the target image can be determined according to the following formula:
[0107]
[0108] Among them, output represents the final classification result of the target image, ω j represents the fusion weight of the jth basic classification model; o j represents the classification result of the jth basic classification model; N represents the number of basic classification models.
[0109] In a feasible implementation, the step of determining the contribution of the plurality of first pixels in the target image to the classification result of the basic classification model in S101 may specifically include the following sub-steps:
[0110] S101-1: Input the basic classification model and the target image into a preset interpretability model to obtain an attribution graph output by the interpretability model.
[0111] In this embodiment, an attribution analysis is performed on the basic classification model based on a preset interpretability model, and an attribution graph of the basic classification model on the target image is generated.
[0112] It should be noted that the attribution map represents the contribution of multiple first pixel points in the target image to the classification result of the basic classification model.
[0113] In this embodiment, by using the interpretable model to generate an attribution graph, it is possible to explain why the basic classification model makes a classification decision on the target image. Specifically, by attributing the decision of the basic classification model to a specific area or feature of the target image, the attribution graph can intuitively understand how the prediction of the basic classification model is affected by different parts of the target image.
[0114] In this embodiment, the attribution map can show the contribution of each pixel or region in the target image to the model output prediction. These contributions can be represented by different color codes, where the intensity of the color is generally proportional to the size of the contribution. For example, for an image classification task, the attribution map may highlight the areas in the image that are most important for the classification decision, such as the edges, textures, or other features of the object.
[0115] In this embodiment, the interpretable model can be constructed based on a preset interpretable algorithm, wherein the interpretable algorithm may include but is not limited to Grad-CAM (Gradient-weighted Class Activation Mapping), Integrated Gradients, Score-CAM (Score-weighted Class Activation Mapping) and LIME (Local Interpretable Model-agnostic Explanations) and other algorithms.
[0116] Reference Figure 2 , showing a flowchart of a model output fusion method. First, the target image is input into the preset j basic classification models respectively, and the j classification results output by the j basic classification models are obtained respectively; then the target image, the j basic classification models and the j classification results are input into the interpretability model, and the j attribution maps corresponding to the j basic classification models are obtained. At the same time, the target image is input into the semantic segmentation model to obtain the mask of the target area in the target image; according to the k second pixel points in the mask, in each attribution map, the k third pixel points with the highest contribution are extracted, and then according to the intersection between the k third pixel points and the k second pixel points, the fusion weight of each basic classification model is determined; finally, the classification results of the j basic classification models are fused according to the j fusion weights to obtain the final classification result for the target image.
[0117] In one example, taking the CUB dataset as an example, the dataset contains 200 bird categories. The CUB dataset is used to train AlexNet (a convolutional neural network, commonly used for image classification), ResNet (Residual Network) and VGG (Visual Geometry Group) to obtain three different types of basic classification models. First, the target image is input into the interpretable model (taking Score-CAM as an example) to obtain the attribution graphs of the three basic classification models for classifying 200 subclasses. Then the target image is input into the pre-trained semantic segmentation model, and the mask of the target area containing the target (i.e., the parent class of bird) is extracted from the segmentation result. The number of pixels in the mask is k, and the intersection of the top k pixels in the attribution graph and the mask is calculated. The three basic models are weighted according to the size of the intersection (for example, weighted voting method) to obtain the final classification results of the three basic classification models for the target image. The larger the size of the intersection corresponding to the basic classification model, the more the basic classification model pays attention to the target in the decision-making process, and the greater the fusion weight of the basic classification model.
[0118] In a feasible implementation, the interpretability model is a first interpretability model, and the first interpretability model is used to perform the following steps:
[0119] S101-1-A1: Input the target image into the basic classification model to obtain the feature map and classification result of the last convolutional layer of the basic classification model.
[0120] In this embodiment, before the target image is input into the basic classification model, the target image can be adjusted to the target format required by the model, which can specifically include adjusting the image size, normalizing the image, and converting it into a tensor format, so as to meet the input requirements of the basic classification model, thereby improving the accuracy of the attribution map visualization.
[0121] In this embodiment, the preprocessed target image is forward-passed through the basic classification model to obtain the feature map and classification result of the last convolutional layer of the basic classification model, and the classification result is the final category score.
[0122] S101-1-A2: Perform back propagation on the classification results to determine the gradient corresponding to the feature map.
[0123] In this embodiment, the classification result output by the last convolutional layer of the basic classification model is back-propagated to calculate the gradient relative to the last layer feature map. The gradient reflects the influence of the input feature on the classification result.
[0124] S101-1-A3: Determine the weight of each channel of the feature map based on the global average value of the gradient.
[0125] In this embodiment, the weight of each channel of the feature map can be calculated by global average pooling of the gradient of the feature map, wherein the weight of the channel represents the importance of the channel to the target category.
[0126] It should be noted that the gradient corresponding to the feature map can be understood as a measure of the "importance" of a specific channel. Therefore, the global average value of each channel is calculated through global average pooling, which is the weight of each channel in the feature map.
[0127] It should be further explained that each channel of the feature map is used to represent the model's response to a specific feature. These features can be edges, textures, shapes, or even some high-level features of objects. Each channel directly corresponds to a different feature learned by the basic classification model.
[0128] S101-1-A4: Perform weighted summation on the feature graph based on the weights to generate an attribution graph.
[0129] In this embodiment, a category-level heat map is generated by weighting the feature map using the calculated weights; then the ReLU activation function is applied to ensure that only positive values are retained, representing the activation area for the classification; finally, the heat map is upsampled to the original image size and superimposed with the target image to obtain a visual heat map, that is, the attribution map of the basic classification model on the target image.
[0130] In this embodiment, the color or brightness in the visualization heat map indicates the contribution of the corresponding region to the classification result. For example, a red or bright region may indicate high importance, while a blue or dark region may indicate low importance.
[0131] In a feasible implementation, the interpretability model is a second interpretability model, and the second interpretability model is used to perform the following steps:
[0132] S101-1-B1: Input the target image into the basic classification model, and obtain multiple channels and first classification scores of the activation map of the last convolutional layer of the basic classification model.
[0133] In this embodiment, by substituting the target image into the basic classification model, a first classification score S of the basic classification model for the target image and n channels of the activation map of the last convolutional layer for outputting the first classification score are obtained, where n is a positive integer greater than or equal to 2.
[0134] It should be noted that the activation map can obtain the corresponding feature map after applying the activation function.
[0135] S101-1-B2: applying multiple channels of the activation map as masks to the target image respectively to generate multiple second images; inputting the multiple second images into the basic classification model respectively to obtain multiple second classification scores.
[0136] In this embodiment, the n channels of the activation map of the last convolutional layer are used as masks and multiplied by the target image respectively to obtain multiple new second images, and the multiple second images are re-input into the basic classification model to obtain n new second classification scores S′.
[0137] S101-1-B3: Based on the first classification score and the plurality of second classification scores, a plurality of score differences are obtained; and based on the plurality of score differences, weights corresponding to the plurality of channels of the activation map are determined.
[0138] In the specific implementation, by subtracting the n second classification scores S′ from the first classification score S, n score differences can be obtained, and the n score differences represent the contribution of each activation map to the increase in the score of the target category; then the n score difference results are processed using the softmax function to obtain the weight of each channel, which represents the importance of each channel for the prediction of the target category.
[0139] S101-1-B4: Generate an attribution map based on the multiple channels of the activation map and the weights corresponding to the multiple channels of the activation map.
[0140] In this embodiment, a weighted activation map sum is obtained by multiplying the weights of n channels with the corresponding n channels and then summing them; a ReLU activation function is then applied to the weighted activation map sum to ensure that all negative values are set to zero, thereby highlighting areas that contribute positively to the prediction; finally, the obtained attribution map is fused with the target image, upsampled and normalized to match the size of the target image, thereby finally obtaining a visualization heat map.
[0141] In this embodiment, the second interpretability model generates an attribution map by assigning weights to the channels of each activation map. These weights are based on the forward pass scores of the channels of the activation map on the target category, thereby getting rid of the dependence on gradients and being unaffected by gradient saturation or vanishing. It can provide clearer and more focused visualization results, reduce background noise, and better explain the model's predictions.
[0142] In a feasible implementation, considering that the first interpretability model is applicable to multiple tasks and the second interpretability model is more robust and can reduce the impact of gradient noise, the first interpretability model and the second interpretability model can be combined to output a more accurate attribution graph. Specifically, the model output fusion method can include the following steps:
[0143] S201: Input the basic classification model and the target image into a preset first interpretability model and a second interpretability model respectively to obtain a first attribution map output by the first interpretability model and a second attribution map output by the second interpretability model.
[0144] In this embodiment, the first interpretability model can execute steps S101-1-A1 to S101-1-A4 to output a first attribution graph; the second interpretability model can execute steps S101-1-B1 to S101-1-B4 to output a second attribution graph. The generation process of the attribution graph is not described in detail here.
[0145] S202: Obtain a first weight coefficient of the first attribution graph and a second weight coefficient of the second attribution graph.
[0146] In this embodiment, the sum of the first weight coefficient and the second weight coefficient is 1, and the first weight coefficient and the second weight coefficient can be determined based on the task type, wherein different task types correspond to different weight coefficients.
[0147] S203: Generate a target attribution graph based on the first attribution graph, the first weight coefficient, the second attribution graph and the second weight coefficient.
[0148] In the specific implementation, the target attribution map of the basic classification model on the target image can be generated according to the following formula:
[0149] Final_Heatmap=α×G1_Heatmap+β×G2_Heatmap;
[0150] Among them, Final_Heatmap represents the target attribution map; α represents the first weight coefficient; G1_Heatmap represents the first attribution map output by the first interpretability model; β represents the second weight coefficient; G2_Heatmap represents the second attribution map output by the second interpretability model.
[0151] In this embodiment, by combining the first interpretability model and the second interpretability model with different implementation principles, the advantages of both models can be fully utilized to generate a more accurate attribution graph, which not only improves the interpretability of the basic classification model, but also helps to develop and adjust the basic classification model to obtain better performance.
[0152] The model output fusion method proposed in the present invention, on the one hand, assigns different weights to each basic classification model according to the reliability of the classification results of the basic classification model, and can adopt adaptive weights to meet the characteristics of different samples when performing model output. Compared with the method of setting weights according to the performance of the basic model on an existing data set, it has better generalization ability; on the other hand, by determining the correctness of the focus area of the basic classification model to compare the output of the basic classification model, compared with the existing model output fusion method, the final output result can be explained and thus have higher reliability.
[0153] In the second aspect, based on the same inventive concept, refer to Figure 3 The embodiment of the present invention provides a model output fusion device 300, and the model output fusion device 300 includes:
[0154] The contribution determination module 301 is used to determine the contribution of multiple first pixel points in the target image to the classification result of the base classification model for any one of the multiple base classification models; the target image is the model input of the multiple base classification models;
[0155] A quantity determination module 302 is used to determine the target quantity of a plurality of second pixel points in a target area in a target image;
[0156] The pixel point determination module 303 is used to determine a plurality of third pixel points with a higher contribution degree among the plurality of first pixel points; the number of the plurality of third pixel points is greater than or equal to the target number;
[0157] A weight determination module 304, configured to determine an intersection of the plurality of third pixels and the plurality of second pixels, and determine a fusion weight of the basic classification model based on the number of pixels in the intersection;
[0158] The fusion processing module 305 is used to perform fusion processing on the classification results corresponding to the multiple basic classification models based on the fusion weights corresponding to the multiple basic classification models, so as to obtain the final classification result for the target image.
[0159] In one embodiment of the present invention, the contribution determination module 301 includes:
[0160] The attribution map generation submodule is used to input the basic classification model and the target image into a preset interpretability model to obtain the attribution map output by the interpretability model; the attribution map represents the contribution of multiple first pixel points in the target image to the classification result of the basic classification model.
[0161] In one embodiment of the present invention, the interpretability model is a first interpretability model, and the attribution graph generation submodule includes:
[0162] The first input unit is used to input the target image into the basic classification model to obtain the feature map and classification result of the last convolution layer of the basic classification model;
[0163] A gradient determination unit, used to perform back propagation on the classification results and determine the gradient corresponding to the feature map;
[0164] A first weight determination unit, configured to determine the weight of each channel of the feature map based on a global average value of the gradient;
[0165] The first attribution graph generating unit is used to perform weighted summation on the feature graph based on the weight to generate an attribution graph.
[0166] In one embodiment of the present invention, the interpretability model is a second interpretability model, and the attribution graph generation submodule includes:
[0167] A second input unit is used to input the target image into the basic classification model and obtain multiple channels and a first classification score of the activation map of the last convolutional layer of the basic classification model;
[0168] A score determination unit is used to apply multiple channels of the activation map as masks to the target image respectively to generate multiple second images; and input the multiple second images into the basic classification model respectively to obtain multiple second classification scores;
[0169] A second weight determination unit is used to obtain a plurality of score differences based on the first classification score and the plurality of second classification scores; and determine the weights corresponding to the plurality of channels of the activation map based on the plurality of score differences;
[0170] The second attribution map generating unit is used to generate an attribution map based on the multiple channels of the activation map and the weights corresponding to the multiple channels of the activation map.
[0171] In one embodiment of the present invention, the quantity determination module 302 includes:
[0172] The semantic segmentation submodule is used to input the target image into a pre-trained semantic segmentation model, output a mask of the target area in the target image, and determine the number of targets of multiple second pixel points in the mask.
[0173] In one embodiment of the present invention, the weight determination module 304 includes:
[0174] A total number determination submodule, used to determine the total number of pixel points of the intersection of multiple basic classification models;
[0175] The weight determination submodule is used to determine the fusion weight of any basic classification model based on the ratio between the number of pixels in the intersection of the basic classification model and the total number of pixels.
[0176] In one embodiment of the present invention, the fusion processing module 305 includes:
[0177] A weighted submodule, for determining, for any basic classification model, a weighted classification result corresponding to the basic classification model based on the classification result corresponding to the basic classification model and a fusion weight;
[0178] The fusion submodule is used to determine the final classification result for the target image based on the weighted classification results corresponding to each of the multiple basic classification models.
[0179] It should be noted that the specific implementation of a model output fusion device 300 in an embodiment of the present invention refers to the specific implementation of the model output fusion method proposed in the first aspect of the above-mentioned embodiment of the present invention, and will not be repeated here.
[0180] In the third aspect, based on the same inventive concept, an embodiment of the present invention provides a computer-readable storage medium on which an executable program is stored. When the executable program is executed by a processor, the model output fusion method proposed in the first aspect of the present invention is implemented.
[0181] It should be noted that the specific implementation of the computer-readable storage medium of the embodiment of the present invention refers to the specific implementation of the model output fusion method proposed in the first aspect of the embodiment of the present invention, and will not be repeated here.
[0182] Fourthly, refer to Figure 4 Based on the same inventive concept, an embodiment of the present invention provides an electronic device 400, including:
[0183] Memory 401, used for storing executable programs;
[0184] Processor 402;
[0185] When the executable program is executed by the processor 402, the model output fusion method proposed in the first aspect of the present invention is implemented.
[0186] It should be noted that the specific implementation of the electronic device 400 in the embodiment of the present invention refers to the specific implementation of the model output fusion method proposed in the first aspect of the embodiment of the present invention, which will not be repeated here.
[0187] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0188] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0189] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0190] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0191] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0192] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0193] The above is a detailed introduction to a model output fusion method, device, storage medium and electronic device provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A model output fusion method, characterized in that: The method comprises: For any basic classification model among a plurality of basic classification models, determining contribution of a plurality of first pixel points in a target image to a classification result of the basic classification model; the target image is a model input of the plurality of basic classification models; Determine the target quantity of a plurality of second pixel points in the target area in the target image; Determine a plurality of third pixel points with the highest contribution among the plurality of first pixel points; the number of the plurality of third pixel points is the target number; Determine an intersection of the plurality of third pixel points and the plurality of second pixel points, and determine a fusion weight of the basic classification model based on the number of pixel points in the intersection; Based on the fusion weights corresponding to the multiple basic classification models, the classification results corresponding to the multiple basic classification models are fused to obtain a final classification result for the target image.
2. The model output fusion method according to claim 1, characterized in that: Determining the contribution of a plurality of first pixels in the target image to the classification result of the basic classification model includes: The basic classification model and the target image are input into a preset interpretability model to obtain an attribution map output by the interpretability model; the attribution map represents the contribution of multiple first pixel points in the target image to the classification result of the basic classification model.
3. The model output fusion method according to claim 2, characterized in that: The interpretability model is a first interpretability model, and the first interpretability model is used to perform the following steps: Input the target image into the basic classification model to obtain the feature map and classification result of the last convolutional layer of the basic classification model; Back-propagating the classification result to determine the gradient corresponding to the feature map; Determining the weight of each channel of the feature map based on the global average value of the gradient; The feature maps are weighted summed based on the weights to generate the attribution map.
4. The model output fusion method according to claim 2, characterized in that: The interpretability model is a second interpretability model, and the second interpretability model is used to perform the following steps: Input the target image into the basic classification model, and obtain multiple channels and first classification scores of the activation map of the last convolutional layer of the basic classification model; Applying multiple channels of the activation map as masks to the target image respectively to generate multiple second images; Inputting the plurality of second images into the basic classification model respectively to obtain a plurality of second classification scores; Based on the first classification score and the plurality of second classification scores, obtaining a plurality of score differences; and determining weights corresponding to each of the plurality of channels of the activation map based on the plurality of score differences; The attribution map is generated based on the multiple channels of the activation map and the weights corresponding to the multiple channels of the activation map.
5. The model output fusion method according to claim 1, characterized in that: Determining the target quantity of a plurality of second pixel points in the target area in the target image comprises: The target image is input into a pre-trained semantic segmentation model, a mask of the target area in the target image is output, and the number of targets of multiple second pixel points in the mask is determined.
6. The model output fusion method according to claim 1, characterized in that: Determining the fusion weight of the basic classification model based on the number of pixels in the intersection includes: Determine the total number of pixels of the intersection of the multiple basic classification models; For any basic classification model, the fusion weight of the basic classification model is determined based on the ratio between the number of pixel points in the intersection of the basic classification model and the total number of pixel points.
7. The model output fusion method according to claim 1, characterized in that: Based on the fusion weights corresponding to the multiple basic classification models, the classification results corresponding to the multiple basic classification models are fused to obtain a final classification result for the target image, including: For any basic classification model, based on the classification result and fusion weight corresponding to the basic classification model, determine the weighted classification result corresponding to the basic classification model; Based on the weighted classification results corresponding to each of the multiple basic classification models, a final classification result for the target image is determined.
8. A model output fusion device, characterized in that: The device comprises: A contribution determination module, used to determine the contribution of multiple first pixel points in a target image to a classification result of any one of multiple basic classification models; the target image is a model input of the multiple basic classification models; A quantity determination module, used to determine the target quantity of a plurality of second pixel points in the target area in the target image; A pixel point determination module, used to determine a plurality of third pixel points with a higher contribution degree among the plurality of first pixel points; the number of the plurality of third pixel points is greater than or equal to the target number; A weight determination module, used to determine the intersection of the plurality of third pixel points and the plurality of second pixel points, and determine the fusion weight of the basic classification model based on the number of pixel points in the intersection; The fusion processing module is used to perform fusion processing on the classification results corresponding to each of the multiple basic classification models based on the fusion weights corresponding to each of the multiple basic classification models, so as to obtain a final classification result for the target image.
9. A computer-readable storage medium having an executable program stored thereon, characterized in that: When the executable program is executed by the processor, the model output fusion method as described in any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: A memory for storing an executable program; processor; When the executable program is executed by the processor, the model output fusion method as described in any one of claims 1 to 7 is implemented.