Picture classification method based on improved attention sketch feature fusion

By introducing improved attention mechanism and sketch feature fusion into the image classification method, the problem of insufficient accuracy and robustness of image classification in the prior art is solved, and more efficient feature extraction and classification performance is achieved.

CN119625410AActive Publication Date: 2025-03-14SHANDONG ARTIFICIAL INTELLIGENCE INSTITUTE +2

Patent Information

Application Number
CN202411719301.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-03-14
Estimated Expiration
2044-11-28

AI Technical Summary

Technical Problem

Existing image classification methods perform poorly when processing complex images, especially when the sample size is small or the category difference is not obvious, model performance is limited and the importance and context information of different regions in the image are ignored, resulting in reduced classification accuracy.

Method used

A sketch feature fusion method based on an improved attention mechanism is adopted, feature extraction is performed through deep convolutional neural networks, and an improved attention mechanism is introduced, feature weights are adaptively adjusted, and feature weights are focused on important areas. At the same time, the characteristics of different levels are fused, and local and global characteristics are combined to form a comprehensive feature representation.

Benefits of technology

It improves the accuracy and robustness of image classification, enhances the model's ability to capture image key information, overcomes the limitations of traditional methods in feature selection and fusion, and is suitable for tasks such as object recognition and scene understanding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119625410A_ABST
    Figure CN119625410A_ABST
Patent Text Reader

Abstract

The invention relates to a picture classification method based on improved attention sketch feature fusion, and belongs to the field of computer image classification. The method comprises the following steps: S1, acquiring a data set which comprises a training set and a test set; s2, constructing a picture classification model based on improved attention sketch feature fusion, wherein the model comprises a sketch encoder, a sketch decoder, a sketch feature extractor, a first original feature extractor, a first attention module, a second original feature extractor, a second attention module, a third original feature extractor and a classifier; s3, using images in the training set to train the model, and using an Adam optimizer to optimize the model through a loss function to obtain a trained model; and S4, the to-be-classified images in the test set pass through the trained model to obtain a classification result. According to the method, the feature information of different levels is combined, an improved attention mechanism and a feature fusion strategy are introduced, and the accuracy and robustness of picture classification are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer image classification, and in particular relates to a picture classification method based on improved attention sketch feature fusion. Background Art

[0002] With the rapid development of computer vision technology, image classification, as an important application scenario, is widely used in medical image analysis, autonomous driving, security monitoring and other fields. Traditional image classification methods mainly rely on manual feature extraction and shallow learning algorithms, which often perform poorly when processing complex images. Therefore, the introduction of deep learning, especially convolutional neural networks (CNNs), has greatly promoted the development of image classification technology. Although deep learning has achieved remarkable results, the performance of the model is still limited in some cases, especially when the sample size is small or the category difference is not obvious. At the same time, existing image classification methods often ignore the importance and contextual information of different regions in the image, resulting in reduced classification accuracy. To make up for these shortcomings, researchers have begun to focus on the attention mechanism, which can dynamically adjust the weights of input features to more effectively capture the key areas in the image. In addition, sketches, as a simplified visual representation, can focus on the contour and shape features of objects, providing a different expression from real images. Fusion of sketch features with traditional image features is expected to enhance the model's ability to understand image content. However, in the field of computer image classification, sketch-based feature fusion methods are still in the initial stage of research, and related technologies need to be improved.

[0003] Therefore, an image classification method based on sketch feature fusion with improved attention mechanism came into being. It aims to improve the accuracy and robustness of classification by effectively integrating image and sketch features, solve the limitations of existing technologies in feature extraction and context understanding, and provide new ideas and methods for the development of intelligent vision systems. Summary of the invention

[0004] In order to improve the accuracy and robustness of image classification, the present invention provides an image classification method based on improved attention sketch feature fusion.

[0005] In order to achieve the above object, the present invention is implemented through the following technical solutions: The present invention provides a picture classification method based on improved attention sketch feature fusion, comprising the following steps: S1. Obtain a publicly available Sketchy dataset and preprocess the images in the dataset, wherein the Sketchy dataset includes a training set and a test set; S2. construct an image classification model based on improved attention sketch feature fusion, the model comprising a sketch encoder, a sketch decoder, a sketch feature extractor, a first original feature extractor, a first attention module, a second original feature extractor, a second attention module, a third original feature extractor, and a classifier; S3. training the model using the images in the training set, and optimizing the model using the Adam optimizer through the loss function to obtain a trained image classification model based on improved attention sketch feature fusion; S4. The images to be classified in the test set are classified by a trained picture classification model based on improved attention sketch feature fusion to obtain classification results.

[0006] Furthermore, in step S1, the image data in the Sketchy dataset is denoised using the FFDnet image denoising method, and the DataSet class in pytorch is used to encapsulate the image data to obtain the Sketchy original image. .

[0007] Furthermore, the sketch encoder in step S2 is composed of a feature extraction layer, a feature encoding layer, and a fully connected layer in sequence, specifically: The feature extraction layer includes a first convolution layer, a ReLU activation function, a first pooling layer, a second convolution layer, a ReLU activation function, a second pooling layer, a third convolution layer, a sigmoid activation function, and a third pooling layer; the feature encoding layer includes a depth convolution layer, a point-by-point convolution layer, a pooling layer, and a channel attention layer; the channel attention calculation formula is as follows: , in, represents the feature map of the input channel attention, ⊙ represents element-by-element multiplication, σ represents the Sigmoid function, Represents the initialization weight matrix of the ReLU function, Represents the initialization weight matrix of the Sigmoid function, express The bias term, express The bias term, Indicates the number of feature map rows, represents the number of feature map columns, represents the activation function, Represents the output of channel attention; the number of units in the fully connected layer is 256, and the activation function is the ReLU activation function; The Sketchy original image Input into the sketch encoder to obtain the sketch encoding feature .

[0008] Furthermore, the sketch decoder in step S2 includes a fully connected layer, a reshaping layer and an upsampling layer, specifically: The number of units in the fully connected layer is 576, and the activation function is the ReLU activation function; the reshape layer uses the Reshape function; the upsampling layer uses transposed convolution; Encode the sketch features Input into the sketch decoder to get the sketch result .

[0009] Furthermore, the sketch feature extractor in step S2 includes a first convolutional layer, a ReLU activation function, a second convolutional layer, a ReLU activation function, and a pooling layer, specifically: The sketch results After inputting into the first convolutional layer and ReLU activation function, the first sketch feature is obtained , drag the first sketch feature Input to the second convolutional layer and ReLU activation function to obtain the second sketch feature , drag the first sketch feature and the second sketch feature Add the input to the pooling layer to get the sketch features .

[0010] Furthermore, in step S2, the first original feature extractor and the first attention module are specifically: The first original feature extractor includes a convolution layer and a sigmoid activation function. After inputting into the convolution layer and sigmoid activation function, it is combined with the sketch features Add to get the first original feature ; The first original feature Input into the first attention module to get the first attention , the formula is as follows: , in, Represents the first original feature , Represents the first original feature The number of channels, H is the first original feature The height of W is the first original feature The width of LayerNorm indicates the normalization layer. represents the output of the first attention module.

[0011] Furthermore, in step S2, the second original feature extractor and the second attention module are specifically: The second original feature extractor includes a first convolution layer, a ReLU activation function, a second convolution layer, a ReLU activation function, a third convolution layer, a pooling layer, a flattening layer and a fully connected layer. and sketch features After addition, it is input into the second original feature extractor to obtain the second original feature ; The second attention module uses a multi-head attention mechanism to and the second original feature Input into the second attention module to get the second attention , the formula is as follows: , in, Represents the second original feature , h represents the number of multi-head attention, , , denote the query matrix, key matrix, and value matrix of the j-th sub-attention learnable of the i-th head, respectively. represents the dimension of the key matrix, represents the learnable adaptive feature selection matrix, and P represents the second original feature The position code, Represents the first original feature , represents the dynamic weight, The calculation formula is as follows: , Among them, the matrix Represents a learnable linear transformation matrix, GlobalContext represents global pooling, represents the multiplication operation, express function.

[0012] Furthermore, the third original feature extractor in step S2 includes a convolution layer, a ReLU activation function, and a pooling layer, and the second original feature and sketch features After addition, it is input into the third original feature extractor to obtain the third original feature .

[0013] Furthermore, the classifier in step S2 is composed of a flattening layer, a first fully connected layer, a second fully connected layer, a third fully connected layer, and a max function in sequence, wherein the first attention and second attention With the third original feature Add together to get improved attention features , the improved attention feature Input the classifier to get the classification result .

[0014] Furthermore, the loss function in step S3 is a cross entropy loss.

[0015] The advantages of the present invention are: The present invention first uses a deep convolutional neural network to extract features from the input image, thereby obtaining a multi-level feature representation. On this basis, an improved attention mechanism is introduced so that the model can focus on areas with important features through adaptive weight allocation, which can enhance the expression ability of key features. Next, the method fuses features at different levels, and effectively combines local features with global features through weighted sum or connection operations to form a comprehensive feature representation. This process ensures that the model can take into account both details and overall information, and improves classification performance. Finally, the fused feature vector is input into the classifier to make the final classification decision, output the probability distribution of each category, and select the predicted final category. In general, this method successfully overcomes the limitations of traditional image classification technology in feature selection and fusion, can more accurately capture the key information in the image, and is widely applicable to a variety of image classification tasks such as object recognition and scene understanding. By introducing an improved attention mechanism and feature fusion strategy, the present invention provides an efficient and powerful solution, laying a foundation for further research and application. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.

[0017] Figure 1 It is a model structure diagram of the method of the present invention; Figure 2 This is a feature visualization comparison diagram of the method of the present invention. DETAILED DESCRIPTION

[0018] 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.

[0019] Example 1 In this embodiment, Figure 1 As shown, the present invention provides an image classification method based on improved attention sketch feature fusion, and the specific steps include: (a) Using the FFDnet image denoising method on the images in the publicly available Sketchy dataset to obtain the Sketchy original image ; Specifically, we obtain image data from the Sketchy dataset and perform FFDnet image denoising on it. We then use the DataSet class in pytorch to encapsulate the original Sketchy image. , the image size is 224×224.

[0020] (b) Sketchy original image Input into the sketch encoder to obtain the sketch encoding feature ; Specifically, b-1) the sketch encoder is composed of a feature extraction layer, a feature encoding layer, and a fully connected layer in sequence. b-2) the feature extraction layer is composed of a first convolutional layer, a ReLU activation function, a first pooling layer, a second convolutional layer, a ReLU activation function, a second pooling layer, a third convolutional layer, a sigmoid activation function, and a third pooling layer. Among them, the convolution kernel size of the first convolutional layer is 3*3, the number of convolution kernels is 32, the stride is 1, and 'same' is used for padding. The first pooling layer adopts maximum pooling, the pooling window size is 2*2, and the stride is 2. The convolution kernel size of the second convolutional layer is 3*3, the number of convolution kernels is 64, the stride is 1, and 'same' is used for padding. The second pooling layer adopts maximum pooling, the pooling window size is 2*2, and the stride is 2. The convolution kernel size of the third convolutional layer is 5*5, the number of convolution kernels is 128, the stride is 1, and 'same' is used for padding. The first pooling layer uses maximum pooling, the pooling window size is 4*4, and the stride is 1. b-3) The feature encoding layer consists of a depth convolution layer, a point-by-point convolution layer, a pooling layer, and a channel attention layer. The convolution kernel size of the depth convolution layer is 3*3, the stride is 1, and 'same' is used for padding. The convolution kernel size of the point-by-point convolution layer is 1*1, and the number of convolution kernels is 32. The pooling layer uses average pooling, the pooling window size is 2*2, and the stride is 2. The channel attention calculation formula is as follows: , in, is the feature map of the input channel attention, that is, the output of the pooling layer, ⊙ represents element-by-element multiplication, σ represents the Sigmoid function, and Represents two initialized weight matrices, the first one maps the input channel number C to a smaller dimension, and the second one maps the output of the activation function back to the original channel number C. and Respectively represent and The two bias terms of Represents the number of feature map rows, Represents the number of feature map columns. Represents the activation function. Represents the output of channel attention. b-4) The number of units in the fully connected layer is 256, and the activation function is the ReLU activation function. b-5) The Sketchy original image Input into the sketch encoder to obtain the sketch encoding feature .

[0021] (c) Encoding features in sketches Input into the sketch decoder to get the sketch result .

[0022] Specifically, c-1) The sketch decoder consists of a fully connected layer, a reshaping layer, and an upsampling layer. c-2) The number of units in the fully connected layer is 576, and the activation function is the ReLU activation function. c-3) The reshaping layer uses the Reshape() function to convert the output of the fully connected layer into a shape of 24*24 suitable for image processing. c-4) The upsampling layer uses transposed convolution to restore the spatial resolution of the image. The transposed convolution kernel size is 3*3, the number of convolution kernels is 64, the stride is 2, and 'same' padding is used. c-5) The sketch encoding features are Input into the sketch decoder to get the sketch result .

[0023] (d) Sketch the result Input into the sketch feature extractor to obtain the sketch feature .

[0024] Specifically, d-1) the sketch feature extractor includes a first convolution layer, a ReLU activation function, a second convolution layer, a ReLU activation function, and a pooling layer. d-2) the convolution kernel size of the first convolution layer is 3*3, the number of convolution kernels is 32, the stride is 1, and 'same' is used for padding. The convolution kernel size of the second convolution layer is 5*5, the number of convolution kernels is 64, the stride is 1, and 'same' is used for padding. The pooling layer uses maximum pooling, the pooling window size is 2*2, and the stride is 2. d-3) the sketch result After inputting into the first convolutional layer and ReLU activation function, the first sketch feature is obtained . Move the first sketch feature Input to the second convolutional layer and ReLU activation function to obtain the second sketch feature . Move the first sketch feature and the second sketch feature Add the input to the pooling layer to get the sketch features .

[0025] (e) Sketchy original image and sketch features Input into the first original feature extractor to obtain the first original feature .

[0026] Specifically, e-1) the first original feature extractor includes a convolution layer and a sigmoid activation function. The convolution kernel size of the convolution layer is 1*1, the number of convolution kernels is 32, the stride is 1, and 'same' padding is used. e-2) The Sketchy original image After inputting into the convolution layer and sigmoid activation function, it is combined with the sketch features Add together to get the first original feature .

[0027] (f) The first original feature Input into the first attention module to get the first attention .

[0028] Specifically, f-1) the calculation formula of the first attention module is as follows: in, is the feature map of the first attention module, that is, the first original feature . is the number of channels of the feature map, H is the height of the feature map, W is the width of the feature map, and LayerNorm() represents the normalization layer. represents the output of the first attention module. f-2) The first original feature Input into the first attention module to get the first attention .

[0029] (g) The first original feature and sketch features Input into the second original feature extractor to obtain the second original feature .

[0030] Specifically, g-1) The second original feature extractor is composed of a first convolutional layer, a ReLU activation function, a second convolutional layer, a ReLU activation function, a third convolutional layer, a pooling layer, a flattening layer, and a fully connected layer. g-2) The convolution kernel size of the first convolutional layer is 3*3, the number of convolution kernels is 64, the stride is 2, and 'same' is used for padding. The convolution kernel size of the second convolutional layer is 1*1, the number of convolution kernels is 256, the stride is 1, and 'same' is used for padding. The convolution kernel size of the third convolutional layer is 3*3, the number of convolution kernels is 512, the stride is 1, and 'same' is used for padding. The pooling layer adopts maximum pooling, the pooling window size is 2*2, and the stride is 2. The flattening layer flattens the pooled output into a one-dimensional vector. The number of units in the fully connected layer is 256. g-3) The first original feature and sketch features After addition, it is input into the second original feature extractor to obtain the second original feature .

[0031] (h) The first original feature and the second original feature Input into the second attention module to get the second attention .

[0032] Specifically, h-1) the second attention module adopts a multi-head attention mechanism, and the calculation formula is as follows: , in, is the feature map input to the second attention module, that is, the second original feature , h represents the number of multi-head attention, here h=4, , , Respectively represent the query matrix, key matrix and value matrix of the j-th sub-attention learnable of the i-th head, through the second original feature The linear transformation yields: Indicates the dimensions of the key matrix. represents a learnable adaptive feature selection matrix, generated by random initialization. P represents the second original feature The position encoding is generated by the embedding() function. Represents the first original feature . Represents dynamic weight, calculated as: Among them, the matrix is a learnable linear transformation matrix used to generate dynamic weights associated with the i-th attention head. GlobalContext() represents global pooling. h-2) The first original feature and the second original feature Input into the second attention module to get the second attention .

[0033] (i) The second original feature and sketch features Input into the third original feature extractor to obtain the third original feature .

[0034] Specifically, i-1) the third original feature extractor is composed of a convolution layer, a ReLU activation function, and a pooling layer. i-2) the convolution kernel size of the convolution layer is 3*3, the number of convolution kernels is 256, the stride is 1, and 'same' padding is used. The pooling layer uses maximum pooling, the pooling window size is 2*2, and the stride is 2. and sketch features After addition, it is input into the third original feature extractor to obtain the third original feature .

[0035] (j) Focus your attention on and second attention With the third original feature Add together to get improved attention features .

[0036] (k) Will improve attention features and sketch features Input into the classifier to get the classification result .

[0037] Specifically, k-1) the classifier is composed of a flattening layer, a first fully connected layer, a second fully connected layer, a third fully connected layer, and a max() function in sequence. k-2) The flattening layer will improve the attention feature and sketch features After addition, they are flattened into a one-dimensional vector along the channel direction. The number of units in the first fully connected layer is 512. The number of units in the second fully connected layer is 128. The number of units in the third fully connected layer is 8. The max() function adds one to the coordinate corresponding to the maximum value in the output of the third fully connected layer, matches it with the classification table dictionary, and outputs the classification result. .

[0038] (l) Use the Adam optimizer to iterate the parameters of the model in steps b) to j) through the loss function to obtain the trained model ; (m) Preprocess the image to be classified and input it into the model trained in step l) to output the classification result. .

[0039] Example 2 In this embodiment, we conducted a comparative experiment. The experimental data set was tested using the public CIFAR-10 data set. The CIFAR-10 data set contains 60,000 32x32 color images, divided into 10 categories, each category containing 6,000 images. These categories include airplanes, cars, birds, cats, deer, dogs, frogs, horses, ships, and trucks. The experimental environment uses Python 3.7, TensorFlow 2.5, and the GPU uses NVIDIA A100 40G. The present invention is compared with the existing mainstream classification methods and implemented under a unified experimental platform. First, the traditional convolutional neural network (CNN) is selected. CNN has become one of the mainstream methods in the field of computer vision with its powerful feature extraction capabilities, parameter efficiency and adaptability, and is widely used in various practical scenarios. Secondly, the FroFA algorithm is selected. The FroFA algorithm is an emerging feature representation method that aims to enhance the performance of the model in feature extraction and classification tasks by introducing a focal attention mechanism.

[0040] Table 1 In this embodiment, Table 1 is a comparison table of experimental parameters, and the accuracy rate indicates the ratio of the number of correctly predicted samples to the total number of samples. The precision rate indicates the ratio of samples predicted as positive examples that are actually positive examples. The recall rate indicates the ratio of samples that are actually positive examples that are correctly predicted as positive examples. F1-score represents the harmonic mean of the precision rate and the recall rate, and measures the balance of the model between the two. The method of the present invention outperforms traditional CNN and FroFA in key performance indicators such as accuracy rate (89.7%), precision rate (88.9%) and F1-score (88.2%), showing that its overall recognition ability and reliability are stronger. Although the recall rate (87.6%) is slightly lower than that of FroFA, this method can still effectively reduce misjudgments and is suitable for scenarios with high precision requirements, proving its superiority in specific tasks.

[0041] In this embodiment, Figure 2 This is a feature visualization comparison diagram of the method of the present invention, showing the comparison of the feature maps obtained by the method of the present invention and CNN in the feature extraction stage. The left side is the feature map extracted by the traditional CNN method, which has less detailed information and obvious background noise. The right side is the feature map extracted by the method of the present invention, which can capture the important features and details in the image more clearly, showing a stronger feature representation ability.

[0042] Through the above experimental data and visualization results, it can be seen that the improved attention sketch feature fusion method of the present invention performs well in the image classification task, not only improving the classification accuracy, but also enhancing the model's ability to handle complex scenes. This proves the effectiveness and practicality of the method of the present invention, and is suitable for wide application in actual image classification tasks.

[0043] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for image classification based on improved attention sketch feature fusion, characterized in that: The following steps are involved: S1. Obtain a publicly available Sketchy dataset and preprocess the images in the dataset, wherein the Sketchy dataset includes a training set and a test set; S2. construct an image classification model based on improved attention sketch feature fusion, the model comprising a sketch encoder, a sketch decoder, a sketch feature extractor, a first original feature extractor, a first attention module, a second original feature extractor, a second attention module, a third original feature extractor, and a classifier; S3. training the model using the images in the training set, and optimizing the model using the Adam optimizer through the loss function to obtain a trained image classification model based on improved attention sketch feature fusion; S4. The images to be classified in the test set are classified by a trained picture classification model based on improved attention sketch feature fusion to obtain classification results.

2. The image classification method based on improved attention sketch feature fusion according to claim 1, characterized in that: In step S1, the image data in the Sketchy dataset is denoised using the FFDnet image denoising method, and the original Sketchy image is obtained by encapsulating it using the DataSet class in pytorch. .

3. The image classification method based on improved attention sketch feature fusion according to claim 1, characterized in that: The sketch encoder in step S2 is composed of a feature extraction layer, a feature encoding layer, and a fully connected layer in sequence, specifically: The feature extraction layer includes a first convolution layer, a ReLU activation function, a first pooling layer, a second convolution layer, a ReLU activation function, a second pooling layer, a third convolution layer, a sigmoid activation function, and a third pooling layer; the feature encoding layer includes a depth convolution layer, a point-by-point convolution layer, a pooling layer, and a channel attention layer; the channel attention calculation formula is as follows: , in, represents the feature map of the input channel attention, ⊙ represents element-by-element multiplication, σ represents the Sigmoid function, Represents the initialization weight matrix of the ReLU function, Represents the initialization weight matrix of the Sigmoid function, express The bias term, express The bias term, Indicates the number of feature map rows, represents the number of feature map columns, represents the activation function, Represents the output of channel attention; the number of units in the fully connected layer is 256, and the activation function is the ReLU activation function; The Sketchy original image Input into the sketch encoder to obtain the sketch encoding feature .

4. The image classification method based on improved attention sketch feature fusion according to claim 1, characterized in that: The sketch decoder in step S2 includes a fully connected layer, a reshaping layer, and an upsampling layer, specifically: The number of units in the fully connected layer is 576, and the activation function is the ReLU activation function; the reshape layer uses the Reshape function; the upsampling layer uses transposed convolution; Encode the sketch features Input into the sketch decoder to get the sketch result .

5. The image classification method based on improved attention sketch feature fusion according to claim 1, characterized in that: The sketch feature extractor in step S2 includes a first convolutional layer, a ReLU activation function, a second convolutional layer, a ReLU activation function, and a pooling layer, specifically: The sketch results After inputting into the first convolutional layer and ReLU activation function, the first sketch feature is obtained , drag the first sketch feature Input to the second convolutional layer and ReLU activation function to obtain the second sketch feature , drag the first sketch feature and the second sketch feature Add the input to the pooling layer to get the sketch features .

6. The image classification method based on improved attention sketch feature fusion according to claim 1, characterized in that: Step S2: The first original feature extractor and the first attention module are specifically: The first original feature extractor includes a convolution layer and a sigmoid activation function. After inputting into the convolution layer and sigmoid activation function, it is combined with the sketch features Add to get the first original feature ; The first original feature Input into the first attention module to get the first attention , the formula is as follows: , in, Represents the first original feature , Represents the first original feature The number of channels, H is the first original feature The height of W is the first original feature The width of LayerNorm indicates the normalization layer. represents the output of the first attention module.

7. The image classification method based on improved attention sketch feature fusion according to claim 1, characterized in that: Step S2: The second original feature extractor and the second attention module are specifically: The second original feature extractor includes a first convolution layer, a ReLU activation function, a second convolution layer, a ReLU activation function, a third convolution layer, a pooling layer, a flattening layer and a fully connected layer. and sketch features After addition, it is input into the second original feature extractor to obtain the second original feature ; The second attention module uses a multi-head attention mechanism to and the second original feature Input into the second attention module to get the second attention , the formula is as follows: , in, Represents the second original feature , h represents the number of multi-head attention, , , denote the query matrix, key matrix, and value matrix of the j-th sub-attention learnable of the i-th head, respectively. represents the dimension of the key matrix, represents the learnable adaptive feature selection matrix, and P represents the second original feature The position code, Represents the first original feature , represents the dynamic weight, The calculation formula is as follows: , Among them, the matrix Represents a learnable linear transformation matrix, GlobalContext represents global pooling, represents the multiplication operation, express function.

8. The image classification method based on improved attention sketch feature fusion according to claim 1, characterized in that: Step S2: The third original feature extractor includes a convolution layer, a ReLU activation function, and a pooling layer. and sketch features After addition, it is input into the third original feature extractor to obtain the third original feature .

9. The image classification method based on improved attention sketch feature fusion according to claim 1, characterized in that: Step S2: The classifier is composed of a flattening layer, a first fully connected layer, a second fully connected layer, a third fully connected layer, and a max function in sequence; the first attention and second attention With the third original feature Add together to get improved attention features ; The improved attention feature Input the classifier to get the classification result .

10. The image classification method based on improved attention sketch feature fusion according to claim 1, characterized in that: The loss function in step S3 is cross entropy loss.

Citation Information

Patent Citations

  • Freehand sketch recognition method based on attention mechanism

    CN112580614A

  • Defect detection method based on joint optimization and mixed attention feature fusion

    CN115294038A

  • Spatial skeleton information-based freehand sketch three-dimensional model reconstruction method

    CN116188690A

  • Remote sensing image target detection method based on fusion convolution attention mechanism

    CN116229295A

  • Hyperspectral and laser radar multilayer fusion classification method based on adversarial learning

    CN117934978A

Cited By

  • Insulin resistance evaluation method based on multi-scale liver pathological image feature fusion

    CN120451675A