A fine-grained image classification method with context-aware component sampling and multi-granularity fusion
By employing context-aware part sampling and part sampling attention mechanisms, the challenge of fusing low-level and high-level features in fine-grained image classification is solved, achieving more efficient fine-grained image classification and improving the model's accuracy and robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUILIN UNIV OF ELECTRONIC TECH
- Filing Date
- 2026-04-23
- Publication Date
- 2026-07-14
AI Technical Summary
Existing technologies struggle to effectively integrate low-level structural details with high-level semantic discriminative information in fine-grained image classification. This results in a lack of contextual constraints in the sampled images, the appearance of pseudo-parts and duplicate sampling, high computational overhead, and insufficient robustness.
We employ a context-aware component sampling and component sampling attention approach, combining dynamic sampling with attention mechanisms to improve key component feature extraction. We also utilize multi-layer feature weighted fusion and introduce a multi-granularity feature backtracking and fusion module to optimize the image classification model.
It improves the accuracy and robustness of fine-grained image classification, generates interpretable feature weight maps, and significantly enhances the model's classification performance under complex conditions.
Smart Images

Figure CN122391733A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision pattern recognition and deep learning technology, and particularly to local discriminative region modeling in fine-grained image classification (FGVC), specifically an image classification method that combines context-aware component sampling and multi-granularity fusion. Background Technology
[0002] Fine-grained image classification tasks are used to distinguish highly similar subclasses within the same broad category (such as bird species, vehicle sub-models, aircraft models, flower varieties, etc.). This task is characterized by "minimal inter-class differences and significant intra-class differences." Objects within the same class may exhibit significant differences due to factors such as pose, scale, occlusion, and lighting, while objects of different classes often show only slight differences in local details.
[0003] The core challenges of fine-grained classification typically focus on:
[0004] (1) Local discrimination region localization and focusing: The model needs to automatically discover the local structures most relevant to the category (e.g., the beak, head feather texture, and wing stripes of birds; the light assembly structure and wheel hub shape of vehicles, etc.).
[0005] (2) Background and pseudo-correlated texture interference suppression: Fine-grained image classification data often have background co-occurrence and shooting bias, and the model is prone to learning "scene shortcuts" rather than the real discrimination area;
[0006] (3) Multi-scale representation and complementarity: Discrimination cues may be distributed at different scales and in different locations, and single attention or single region modeling is often insufficient.
[0007] To address the aforementioned issues, existing technologies typically include: A. Strongly supervised component / keypoint routes rely on keypoint or component bounding box annotations for alignment and local cropping, offering high performance but incurring high annotation costs and poor transfer; B. Weakly supervised attention / saliency routes are based on CAM self-attention focusing regions, which are prone to collapse to the most salient region and are susceptible to background interference; C. Multi-region / multi-instance learning routes generate multiple candidate regions and then aggregate them, which easily introduces noise and incurs high computational costs; D. Local sampling / component modeling routes learn and fuse multiple part representations on feature maps, with the key bottleneck being the quality of the generated sampling map.
[0008] In component sampling schemes, the common basic form is:
[0009]
[0010] in For a certain layer of features, For sampling images, This is a component vector. While this form is simple and effective, a "structure-semantic dilemma" arises when the sampling map is generated from only a single layer of features:
[0011] If generated from high-level semantic features, the semantics are strong but the resolution is low and the localization is coarse.
[0012] If generated from shallow detail features, it has high resolution but weak semantics and is prone to missampling of background texture.
[0013] Furthermore, multi-stage backbone networks naturally generate hierarchical information, with shallow layers containing structural details and higher layers containing semantic discrimination. If the sampling process does not explicitly utilize cross-layer information, the advantages of multi-scale processing cannot be fully realized; the lack of contextual constraints in the sampling graph can also lead to pseudo-components and duplicate sampling.
[0014] Therefore, a new technical solution is needed to integrate shallow structural details and high-level semantic discrimination information in component sampling, so that the generated sampling map has context awareness capabilities and high-level semantic features are sampled and aggregated to obtain a more stable and complementary component representation for fine-grained classification. Summary of the Invention
[0015] The purpose of this invention is to provide a fine-grained image classification method based on context-aware part sampling and part sampling attention. Addressing the challenges of low-level and high-level feature fusion and part-level feature extraction in fine-grained image classification, this invention first designs a context-aware part sampling module, which improves the extraction and enhancement of key part features by combining dynamic sampling with an attention mechanism. Second, combined with the part sampling attention module, feature weighting at the part level further optimizes the accuracy of the image classification model. The overall method works collaboratively through multiple modules, including a backbone feature extraction network, a context-aware part sampling module, a part sampling attention module, a multi-granularity feature backtracking and fusion module, and a classification head module, thereby improving the overall performance of fine-grained image classification.
[0016] The technical solution adopted in this invention is as follows:
[0017] A context-aware component sampling and multi-granularity fusion image classification method, characterized by comprising the following steps:
[0018] S1: Dataset Construction. During implementation, publicly available fine-grained image classification datasets are first screened and preprocessed, divided into training and validation sets. Input images are standardized, and data augmentation techniques such as random cropping, flipping, and color perturbation are used to improve the model's robustness to visual disturbances such as lighting, background, and pose changes.
[0019] S2: Construct a fine-grained image classification network. The overall network utilizes context-aware part sampling and part sampling attention modules to improve performance. The backbone network is responsible for extracting multi-level features from the input image, which are then fed into subsequent modules. The core idea is to extract discriminative features from the multi-level features output by the backbone network using context-aware and attention mechanisms, and finally perform prediction through a classification head.
[0020] S2.1: Backbone Feature Extraction Network. This part can use a Convolutional Neural Network (CNN) or a Transformer structure. The input is the original image, and the output is a multi-scale feature map of four stages. , , , The feature size and number of channels change progressively at each stage, with higher-level features used for subsequent part sampling and attention enhancement, while lower-level features are used to capture detailed information.
[0021] S2.2: Context-Aware Component Sampling Module. The core of this module is to dynamically select key components by combining low-level and high-level features. First, the high-level features are upsampled to align with the spatial resolution of the low-level features, thereby achieving effective fusion of detailed and semantic information.
[0022] Next, feature fusion is performed using a gating mechanism. Low-level features are concatenated with upsampled high-level features, and gating coefficients are calculated using a multilayer perceptron (MLP). Used for weighted generation of context-aware feature representations:
[0023]
[0024] Here, ⊙ represents element-wise multiplication. These are the final characteristics after fusion.
[0025] Subsequently, the fused features are transformed into components through linear transformation. It also overlays learnable location codes to perceive location relationships:
[0026]
[0027] To control the "sharpness" of the sampled image, the module employs a temperature scaling mechanism. After temperature scaling of the logits, Softmax is applied to obtain the component sampled image. :
[0028]
[0029] τ is a learnable temperature parameter, which can be adjusted to control the model's focus on key information.
[0030] Using sampling map The upsampled high-level features are weighted and converged, then projected onto a new feature space to obtain component features. :
[0031]
[0032] Through this process, the module is able to extract component features that are useful for fine-grained classification based on multi-layer features.
[0033] S2.3: Component Sampling Attention Module. This module weights component features using an attention mechanism. First, query features and component features are mapped to query keys and values, respectively:
[0034]
[0035] The similarity between the query and the key is calculated using a multi-head attention mechanism to obtain the attention weights. And based on this, the values are weighted and aggregated:
[0036]
[0037] in This is a learnable attentional location bias.
[0038] To improve robustness, a component importance assessment module is introduced to calculate the importance score of each component and combine it with attention weights to obtain the final enhanced features:
[0039]
[0040] This mechanism can significantly improve classification accuracy and generate interpretable feature weight maps.
[0041] S2.4: The multi-granularity component backtracking and fusion module enhances performance by backtracking features from different stages. In cross-layer backtracking mode, features from each stage are normalized and fused with higher-level features, then enhanced with attention. Finally, the output features from all stages are concatenated to obtain multi-granularity global features.
[0042]
[0043] S2.5: Feature Aggregation and Classification Head. A feature weighted pooling method is used to aggregate features from all components, resulting in an image-level feature representation. The aggregated features are then processed by a classification head (containing weights). and bias Perform classification prediction:
[0044]
[0045] S2.6: Loss Function Design. During training, the cross-entropy loss function is used to optimize the classification results. Optionally, a saliency consistency constraint can be introduced. By calculating the consistency loss between Grad-CAM saliency and feature weights, the network is constrained to focus on the discriminative region.
[0046]
[0047] S3: Training strategy, employing a standard deep learning framework and batch processing for training. The Adam optimizer is used, and the learning rate is adjusted according to the training stage. Data augmentation techniques such as mix-up are used to prevent overfitting. Output is calculated through forward propagation, and parameters are updated through backpropagation.
[0048] S4: Inference Process. In the inference phase, the trained model is used to classify new images. First, the input image is preprocessed, including normalization, resizing, and data augmentation, to ensure consistency with the training data. The processed image is fed into the backbone feature extraction network, which extracts features from low to high levels, including edge textures, object contours, and semantic information. Then, the low- and high-level features are aligned and weighted by the context-aware part sampling module to combine details and semantic information. Next, the part features are enhanced by the part sampling attention module, which adjusts feature weights by calculating similarity to focus on important part features. Finally, the classification head module maps the fused features to the category space and calculates the probability of each category using the Softmax function, selecting the category with the highest probability as the prediction result. Through these steps, the model efficiently completes the image classification task. Attached Figure Description
[0049] Figure 1 This is a diagram showing the overall network structure of the method of the present invention;
[0050] Figure 2 This is a diagram of the context-aware component sampling module in the method of the present invention;
[0051] Figure 3 This is a diagram of the component sampling attention module in the method of the present invention;
[0052] Figure 4 This is a summary diagram of the specification for the method of the present invention. Detailed Implementation
[0053] This invention provides a fine-grained image classification method based on context-aware part sampling and part sampling attention. This method improves the recognition accuracy of image classification models by combining low-level and high-level features to perform fine-grained feature learning at the part level. The overall network architecture of this method is shown in the attached figure, including multiple modules, mainly: a backbone feature extraction network, a context-aware part sampling module, a part sampling attention module, a multi-granular feature backtracking and fusion module, and a classification head module. The specific implementation process of each module is described in detail below with reference to the attached figures.
[0054] Step 1: Constructing the dataset. In this process, we first screen and preprocess publicly available fine-grained image classification datasets to obtain training and validation sets. Input images are standardized, and data augmentation techniques such as random cropping, flipping, and color perturbation are used to improve the model's robustness to various visual disturbances. Through these processes, the dataset can cover various transformations in image classification tasks, such as changes in lighting, background, and pose.
[0055] Step 2: Construct a fine-grained image classification network. In fine-grained image classification tasks, the method of this invention utilizes context-aware part sampling and part sampling attention modules to improve model performance. The overall network structure diagram is shown below. Figure 1 As shown, the network comprises multiple modules. The backbone network is responsible for extracting multi-level features from the input image. These features are then fed into the context-aware part sampling module and the part sampling attention module. The core idea of the network is to extract more discriminative features from the multi-level features output by the backbone feature extraction network using context-aware part sampling and part sampling attention mechanisms, respectively. Finally, a classification head is used for classification prediction.
[0056] Step 2.1: Backbone Feature Extraction Network. This part of the network structure can adopt a traditional Convolutional Neural Network (CNN) or Transformer structure. The input of the backbone network is the original image, and the output is multiple feature maps at different scales. The output form of the feature maps is multiple sets of feature sequences, where the feature sequence of each stage can be represented as a two-dimensional flattened token sequence. Specifically, the feature map can be divided into four stages: , , , In this process, the feature size and number of channels gradually decrease at each stage, but the semantic information gradually increases. The final high-level features are used for subsequent part sampling and attention enhancement, while the low-level features are used to capture detailed information.
[0057] Step 2.2: Context-Aware Component Sampling Module
[0058] The core task of the context-aware component sampling module is to dynamically select and enhance key components by combining low-level and high-level features, thereby helping fine-grained image classification models identify important regions in images. The overall module flow is as follows: Figure 2 As shown, this module first receives low-level features. and high-level characteristics The high-level features are then upsampled to align with the low-level features, resulting in an upsampled version of the high-level features. This process enables the effective fusion of detailed information from low-level features with semantic information from high-level features. Specifically, the dimensions of the low-level features and the upsampled high-level features are as follows:
[0059]
[0060] in, For batch size, and These represent the spatial resolutions of the low-level and high-level feature maps, respectively. and These represent the corresponding number of channels.
[0061] Next, a gating mechanism is used to fuse low-level and high-level features. Specifically, the low-level features are concatenated with the upsampled high-level features, and a gating coefficient g is calculated using a multilayer perceptron (MLP). This coefficient determines how to weight the low-level and high-level features to generate a context-aware feature representation. The formula for calculating the gating coefficient is as follows:
[0062]
[0063] Where σ(⋅) is the Sigmoid activation function, and finally, the low-level and high-level features are weighted and summed to obtain the fused features:
[0064]
[0065] Here, ⊙ represents element-wise multiplication. This represents the final fused feature representation.
[0066] Next, the fused features are transformed using a linear transformation to generate a logits value L for each component, representing the response intensity of the component at different locations. To enhance the model's expressive power, positional encoding can also be superimposed on the features, enabling the model to perceive positional relationships within the image. The formula for calculating the component logits is:
[0067]
[0068] in, These are trainable linear transformation parameters. For bias terms, It is a learnable location encoding.
[0069] To control the "sharpness" of the sampling image, the module employs a temperature scaling mechanism. Specifically, after temperature scaling of the logits, the Softmax function is applied to obtain the component sampling image S, which represents the importance of each component at different spatial locations.
[0070]
[0071] Here, τ is a learnable temperature parameter. By adjusting the temperature parameter, the model can control the smoothness of the sampled image, thereby improving the model's ability to focus on key information.
[0072] Using sampling map The upsampled high-level features are weighted and converged to obtain component features. This weighted convergence process can highlight key feature characteristics in an image, helping fine-grained classification tasks to better identify target parts. The weighted convergence formula is as follows:
[0073]
[0074] in, It is a sampling image. These are high-level features after upsampling.
[0075] Finally, the component features are projected onto a new feature space through a linear transformation to obtain the projected component features. :
[0076]
[0077] Through this series of operations, the context-aware component sampling module is able to extract component features useful for fine-grained classification based on multi-layer features.
[0078] Step 2.3: Component Sampling Attention Module
[0079] The core purpose of the component sampling attention module is to enhance the representation capability of key components by weighting component features through an attention mechanism. The module flow is as follows: Figure 3 As shown, the input to this module is the query token characteristics. and component features obtained through the context-aware component sampling module First, the query vector is obtained through a linear transformation. And map component features to key-value pairs :
[0080]
[0081] in, and These are trainable linear transformation parameters, corresponding to the mapping of query keys and values, respectively.
[0082] The similarity between the query and the key is calculated using a multi-head attention mechanism to obtain the attention weights. And based on these weights, the values Weighted aggregation is performed. The formula for calculating attention weights is as follows:
[0083]
[0084] in, For each dimension of attention head, To provide learnable attention position biases, the Softmax operation normalizes across the component dimensions. This allows the model to dynamically adjust the importance of each component within the global token.
[0085] Ultimately, attention weights and component features Multiplication yields attention-enhanced component features. The formula is:
[0086]
[0087] This process significantly enhances the representation of important components in the image, enabling the model to perform finer-grained classification.
[0088] To further enhance the robustness of the model, this invention also introduces a component importance evaluation module. This module globally aggregates component features and calculates the importance score for each component to obtain an importance vector. The formula is as follows:
[0089]
[0090] Then, the model will assign attention weights and component importance weight Combined, the final enhanced features are obtained through scaling operations:
[0091]
[0092] Through this mechanism, the component sampling attention module can significantly improve the accuracy of image classification tasks, while generating interpretable feature weight maps to help analyze the model's decision-making basis.
[0093] Step 2.4: Multi-granularity component backtracking and fusion
[0094] The multi-granularity component backtracking and fusion module enhances fine-grained classification performance by backtracking features from different stages. In cross-layer backtracking mode, features from each stage are normalized and fused with higher-level features to generate component features. These component features are enhanced by the component sampling attention module, and finally, the output features from all stages are concatenated and fused to obtain global features with multi-granularity information.
[0095] Without using a cross-layer backtracking approach, this method utilizes only high-level features for component sampling and attention enhancement, making it suitable for computationally demanding scenarios. In this way, the network can generate rich feature representations based on information from different levels, enhancing its ability to capture fine-grained information.
[0096]
[0097] in, The output features of the four stages are concatenated to obtain the final multi-granularity fused features.
[0098] Step 2.5: Feature Aggregation and Classification Header
[0099] In the feature aggregation stage, a weighted pooling method is used to aggregate all component features to obtain the final image-level feature representation. This process normalizes the feature weights to ensure that important component features receive higher weights during aggregation. Finally, the aggregated features are classified using a classification head to obtain the classification result.
[0100]
[0101] in, As the weight of the classification head, is the bias term, and GELU is the activation function.
[0102] Step 3: Training Strategy
[0103] During training, a standard deep learning framework was employed, and batch processing was used for model training. The Adam optimizer was used during training, and the learning rate and other hyperparameters were adjusted according to different training stages. To prevent overfitting, mix-up data augmentation was used during training. The model output was obtained through forward propagation, and the network parameters were updated through backpropagation, progressively optimizing the classification accuracy.
[0104] Step 4: Reasoning Process
[0105] During the inference phase, the trained model is used to classify new images. First, the input images to be classified need to be preprocessed. These preprocessing steps include normalization, resizing, and other possible data augmentation methods to ensure that the format of the input images is consistent with the image data used during training. The image size is resized to match the network's input requirements, and the RGB channel values are typically standardized by subtracting the mean and dividing by the standard deviation. After preprocessing, the image is fed into the backbone feature extraction network for feature extraction. At this stage, the network extracts different levels of feature information from the input image through multiple layers of convolutions or the Transformer self-attention mechanism. These features, from low to high levels, include edge textures, object contours, and high-level semantic information. The output of the backbone network typically contains feature maps from multiple stages, such as... , , , Among them, high-level characteristics Contains richer semantic information, low-level features This helps to capture more details.
[0106] Next, these low-level and high-level features are processed by a context-aware part sampling module. In this module, low-level and high-level features are upsampled and aligned to ensure effective fusion. Weighted fusion of low-level and high-level features is performed by calculating gating coefficients, allowing the model to utilize both low-level details and high-level semantic information simultaneously. Then, the part features are passed to a part sampling attention module, which enhances key part features using an attention mechanism. By calculating the similarity between the query vector and the key-value pair, the model adjusts the weights of each part based on its importance, enabling the network to focus on the most discriminative part features. Finally, these attention-weighted part features are classified by a classification head module. The classification head maps the multi-granularity fused features to a class space and calculates the probability of each class using a Softmax function. During inference, the network selects the class with the highest probability as the final prediction. Through this series of steps, the model can efficiently classify new images during the inference phase.
[0107] This invention effectively improves the performance of fine-grained image classification tasks through context-aware part sampling and part sampling attention mechanisms. The context-aware part sampling module can find key part features in multi-layer features, while the part sampling attention module uses an attention mechanism to weight and converge these part features, enabling the model to focus on important discrimination regions in the image. Finally, through feature aggregation and a classification head, the network can generate accurate classification results.
[0108] Dataset method CUB STANFORD DOGS TransFG 90.8 92.3 IELT 90.8 91.8 TransIFC 90.9 91.9 MP-FGVC 91.0 91.0 ACC-VIT 91.8 92.9 Ours 92.5 93.4
[0109] Table 1. Comparison of the method of this invention with five other methods on the CUB and STANFORD DOGS datasets.
[0110] Table 1 shows the accuracy results of this invention and other excellent fine-grained image classification methods on the CUB and STANFORD DOGS datasets. The CUB dataset contains 11,788 images of 200 fine-grained bird categories, with various complex shooting conditions, such as different shooting angles, poses, lighting, and backgrounds. The STANFORD DOGS dataset contains 20,580 images of 120 fine-grained canine categories, also covering different viewing angles and environmental conditions. The fine-grained classification algorithms compared include TransFG, IELT, TransIFC MP-FGVC, and ACC-VIT. The data in the table shows that the algorithm of this invention achieves the best results on both the CUB and STANFORD DOGS datasets, with accuracies of 92.5% and 93.4%, respectively. This indicates that this invention has a significant advantage over other existing methods in fine-grained image classification tasks.
Claims
1. An image classification method for context-aware part sampling and multi-granularity fusion applied to fine-grained image classification, the method comprising the following steps: S1: Input and preprocessing; S2: Multi-stage backbone network feature extraction to obtain multi-scale features; S3: Context-aware component sampling module, which uses shallow structural details and high-level semantic information to generate component sampling maps; S4: Component sampling attention module, which uses sampled component features to perform attention interaction with high-level features and generates enhanced features; S5: Multi-granularity feature fusion and classification head prediction, outputting class probability. in, In step S3, features of each shallow stage are analyzed. Characteristics of high-level stages After spatial / channel alignment, gated fusion is performed to obtain fusion guidance features, and component sampling probability maps are generated based on these fusion guidance features. Then, the high-level features are weighted and sampled to generate component features, and the component features are projected to maintain compatibility with the input dimensions of the subsequent attention module.
2. The method according to claim 1, characterized in that, Step S1 includes: S1.1: Obtain the input image ; S1.2: Perform scale normalization, random or center cropping, color perturbation, and standardization on the input image to obtain the network input. ; S1.3: Input the network Combining by batch .
3. The method according to claim 1, characterized in that, Step S2 includes: S2.1: Will Inputting a multi-stage backbone network yields four stages of output features: in As a high-level semantic feature ; S2.2: Represent the features of each stage as a two-dimensional feature map: S2.3: Optionally, the two-dimensional feature map is flattened into a token sequence: Then proceed to step S3.
4. The method according to claim 1, characterized in that, Step S3 for any stage ∈{1,2,3,4} contains the following sub-steps: S3.1: Spatial alignment from high-level to shallow-level: in =1024. S3.2: Shallow-to-high-level channel alignment, aligning shallow feature channels to high-level channel dimensions: in The linear mapping is a 1x1 convolution. S3.3: Gated fusion yields fusion-guided features, which are then used to construct splicing features and calculate the gating coefficients. in It is Sigmoid; This is a gated network. The fused guided features are obtained by fusing the gating coefficients. This gating fusion exists in all four stages, and the input dimension of the gating network is equal to "shallow dimension + high-level dimension". S3.4: The sampling logit and component number are set, and a linear mapping is performed on the fusion guiding feature or its concatenated features to obtain the component sampling logits: S3.5: Temperature-based softmax is used to obtain the sampling probability map. Logits are flattened in space and then subjected to temperature-based softmax. Where τ>0 is the temperature parameter, which can be learned or preset to adjust the sparsity and kurtosis of the sampling distribution. S3.6: Weighted convergence of high-level semantic features yields component vectors, and the high-level semantic features are upsampled to... , And flatten: Flatten the sampling image as follows: The component features are: in =1024. S3.7: Output projection maintains dimension compatibility, projecting component features onto the stage output dimension: Then proceed to step S4.
5. The method according to claim 1, characterized in that, Step S4 for any stage Includes the following sub-steps: S4.1: High-level characteristics For querying, by component features Generate keys and values, and construct attention: S4.2: Calculate attention weights and obtain the enhanced representation: S4.3: The enhanced representation is mapped to the output and fused with the original high-level feature residuals to obtain the output enhanced features for this stage. : Then we move on to S5.
6. The method according to claim 1, characterized in that, Step S5 includes: S5.1: Collect enhancement features from each stage and perform multi-granularity stitching: S5.2: Normalize and dropout the spliced features: S5.3: Output category logits via a linear classification header: S5.4: Obtain class probabilities using softmax: The above are the detailed steps of the method.
7. The method according to any one of claims 1 to 6, characterized in that, The context-aware component sampling module includes the following steps: Step 1: Receive feature maps from multiple stages and align them; Step 2: Align the high-level features with the same spatial scale as the shallow features through upsampling; Step 3: Generate fused features by splicing shallow features with aligned high-level features; Step 4: Weight the fused features using a learnable gating mechanism to generate a component sampling map; Step 5: Based on the generated component sampling map, weighted convergence of component features is performed from high-level features; Step 6: Map the component features to the target space using linear projection, and output the final component feature vector.
8. The method according to any one of claims 1 to 7, characterized in that, The component sampling attention module includes the following steps: Step 1: Receive component features from the context-aware component sampling module and spatial features from the backbone network; Step 2: Map component features to keys and values, and spatial features to queries; Step 3: Calculate the similarity between the query and the key, and generate an attention score based on the similarity. Step 4: Weight the values using attention scores to obtain the enhanced feature representation; Step 5: Combine the enhanced features with the original spatial features through residual connections to obtain the final output features; Step 6: Generate a feature weight map for subsequent multi-granularity feature fusion.
9. The method according to any one of claims 1 to 8, characterized in that, The multi-granularity feature fusion module includes the following steps: Step 1: Perform global pooling on the augmented features from different stages to obtain the global feature representations for each stage; Step 2: Concatenate the global feature representations of each stage according to the channel dimension to form multi-granularity fused features; Step 3: Map the concatenated multi-granularity features to the final classification space through linear transformation; Step 4: Input the mapped features into the classification head and output the category prediction results.