A convolution and self-attention hybrid image feature extraction method, device and equipment

By combining convolution and self-attention, and integrating local and global feature extraction, this approach solves the problem that existing image feature extraction techniques cannot simultaneously acquire global and local information, achieving more efficient feature extraction and more stable feature analysis.

CN118570491BActive Publication Date: 2026-11-24HANGZHOU ANMAISHENG INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410920294.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2026-11-24
Estimated Expiration
2044-07-10

AI Technical Summary

Technical Problem

Existing image feature extraction methods cannot simultaneously acquire global and local information about objects, leading to detection bias, especially in object detection and semantic segmentation tasks, where the recognition accuracy is low and the robustness is poor.

Method used

A hybrid approach combining convolution and self-attention is adopted. Image data is processed through N×N and 1×1 convolutional layers. Local and global self-attention modules are combined to extract local and global features and perform feature fusion. The local feature extraction of the local self-attention module and the global feature extraction of the global self-attention module are combined with the local subtle features of the convolutional layer and the long-distance dependency information of self-attention.

Benefits of technology

It improves the performance of image feature extraction, especially maintaining stability in scenes with large changes in object scale, and enhances the accuracy and robustness of feature analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570491B_ABST
    Figure CN118570491B_ABST
Patent Text Reader

Abstract

The application discloses a convolution and self-attention hybrid image feature extraction method, device and equipment, applied to the technical field of image processing, comprising: input image data is processed by using N*N convolution layer and 1*1 convolution layer, and convolution processing data is obtained; local feature extraction is carried out on the input image data by using a local self-attention module, and local features are obtained; the local features and the convolution processing data are fused and processed, and fusion data is obtained; global feature extraction is carried out on the fusion data and the convolution processing data by using a global self-attention module, and global features are obtained; the global features and the local features are fused, and fusion image features are obtained. The application carries out feature extraction in the cross processing mode of image data in two methods, which not only plays the advantage that convolution focuses on local subtle features, but also combines the ability that self-attention captures long-distance dependent information, so that the effect of image feature extraction is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method, apparatus, and device for image feature extraction using a hybrid convolution and self-attention approach. Background Technology

[0002] In object detection and semantic segmentation tasks, image feature extraction is the most crucial step. Most past image feature extraction algorithms have focused on improving traditional handcrafted features such as gradient histograms, color, and texture. While these algorithms offer fast execution speeds, their recognition accuracy is low and their robustness is poor.

[0003] Convolutional neural networks (CNNs) extract features by sliding convolutional kernels across an image, focusing only on local information. By stacking multiple convolutional layers, CNNs can extract features at different levels from the input image data. This hierarchical feature extraction approach allows the model to better understand and process complex image data. However, simply stacking multiple convolutional layers cannot obtain global receptive field information. In visual tasks such as object detection, it cannot capture all information about objects (especially large objects), leading to detection bias.

[0004] Therefore, current image feature extraction methods suffer from poor image feature extraction performance. Summary of the Invention

[0005] In view of this, the purpose of the present invention is to provide a method, apparatus and device for image feature extraction that combines convolution and self-attention, thereby solving the technical problem of poor image feature extraction performance in the prior art.

[0006] To address the aforementioned technical problems, this invention provides a method for image feature extraction combining convolution and self-attention, comprising:

[0007] The input image data is processed using N×N convolutional layers and 1×1 convolutional layers to obtain convolutional processed data;

[0008] The input image data is processed using a local self-attention module to extract local features, thus obtaining local features.

[0009] The local features and the convolutional data are fused together to obtain fused data;

[0010] Global features are obtained by using a global self-attention module to extract global features from the fused data and the convolutional processed data.

[0011] The global features and the local features are fused to obtain fused image features.

[0012] Optionally, after extracting local features from the input image data using a local self-attention module, the method further includes:

[0013] The local features and the fused data are convolved using an N×N convolutional layer to obtain fused local data.

[0014] Accordingly, fusing the global features and the local features to obtain fused image features includes:

[0015] The global features and the fused local data are fused to obtain the fused image features.

[0016] Optionally, the step of fusing the local features and the convolutional data to obtain fused data includes:

[0017] The local features and the convolutional data are fused together to obtain initial fused data;

[0018] The initial fused data is randomly shuffled to obtain the fused data.

[0019] Optionally, after fusing the local features and the convolutional processing data to obtain fused data, the method further includes:

[0020] The fused data is divided into two parts to obtain the first fused data and the second fused data.

[0021] Accordingly, the step of using a global self-attention module to extract global features from the fused data and the convolutional processed data to obtain global features; and fusing the global features and the local features to obtain fused image features, includes:

[0022] The global self-attention module is used to extract global features from the first fused data and the convolutional processed data to obtain the global features.

[0023] The local features and the second fused data are processed using an N×N convolutional layer to obtain convolutional local features;

[0024] The convolutional local features and the global features are fused to obtain the fused image features.

[0025] Optionally, after fusing the global features and the local features to obtain the fused image features, the method further includes:

[0026] The fused image features are processed using a 1×1 convolutional layer to obtain the final fused image features.

[0027] Optionally, the process of local feature extraction includes:

[0028] The input image data is divided into equal parts by a window to obtain equal parts data. The self-attention QKV matrix is ​​calculated for each of the equal parts data to obtain the corresponding target equal parts data.

[0029] The target equally divided data is reconstructed and restored to obtain reconstructed input image data;

[0030] The reconstructed input image data is divided into three parts, which are then fed into three fully connected layers with an output dimension of d for data computation, respectively, to obtain feature matrices Q, K, and V. These three feature matrices are then used to calculate the local features according to the local self-attention formula.

[0031] Optionally, after fusing the global features and the local features to obtain the fused image features, the method further includes:

[0032] The fused image features are input into a target detection model or a semantic segmentation model for feature analysis to obtain the target processing result.

[0033] This application also provides a hybrid image feature extraction device combining convolution and self-attention, comprising:

[0034] The convolution processing module is used to process the input image data using N×N convolutional layers and 1×1 convolutional layers to obtain convolutional processed data;

[0035] The local feature extraction module is used to extract local features from the input image data using the local self-attention module to obtain local features;

[0036] The information cross-processing module is used to fuse the local features and the convolutional processing data to obtain fused data;

[0037] A global feature extraction module is used to extract global features from the fused data and the convolutional processed data using a global self-attention module to obtain global features.

[0038] The local and global fusion module is used to fuse the global features and the local features to obtain fused image features.

[0039] This application also provides a hybrid image feature extraction device combining convolution and self-attention, comprising:

[0040] Memory, used to store computer programs;

[0041] A processor is configured to implement the steps of the above-described convolutional and self-attention hybrid image feature extraction method when executing the computer program.

[0042] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described convolutional and self-attention hybrid image feature extraction method.

[0043] As can be seen, this invention processes input image data using N×N and 1×1 convolutional layers to obtain convolutional processed data; it then uses a local self-attention module to extract local features from the input image data to obtain local features; the local features and the convolutional processed data are fused to obtain fused data; a global self-attention module is used to extract global features from the fused data and the convolutional processed data to obtain global features; and finally, the global features and local features are fused to obtain fused image features. This application uses a cross-processing approach between two methods for feature extraction of input image data. This leverages the advantage of convolution in focusing on subtle local features while combining the ability of self-attention to capture long-range dependencies, thereby improving the image feature extraction effect. This maintains good stability in specific scenarios, such as industrial defect detection, where object scale changes significantly.

[0044] In addition, the present invention also provides a hybrid image feature extraction apparatus, device, and computer-readable storage medium that combines convolution and self-attention, which also have the aforementioned beneficial effects. Attached Figure Description

[0045] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0046] Figure 1 A flowchart illustrating a hybrid image feature extraction method combining convolution and self-attention, as provided in an embodiment of the present invention;

[0047] Figure 2 A flowchart illustrating a hybrid image feature extraction method combining convolution and self-attention, provided in an embodiment of the present invention;

[0048] Figure 3 This is a schematic diagram of the overall structure for image feature extraction using a hybrid convolution and self-attention method, provided in an embodiment of the present invention.

[0049] Figure 4 A flowchart illustrating the calculation of a local self-attention block provided in an embodiment of the present invention;

[0050] Figure 5A flowchart illustrating a self-attention computation method provided in an embodiment of the present invention;

[0051] Figure 6 This is a schematic diagram of the structure of a hybrid image feature extraction device combining convolution and self-attention, provided in an embodiment of the present invention.

[0052] Figure 7 This is a schematic diagram of the structure of a hybrid image feature extraction device combining convolution and self-attention, provided in an embodiment of the present invention. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0054] Self-attention mechanisms can directly compute the dependency between any two positions in the input sequence, thereby effectively capturing long-distance dependency information and understanding image content through global information. However, self-attention lacks spatial inductive bias and is not sensitive to positional information, which is not friendly to visual tasks such as object detection and cannot accurately locate objects.

[0055] Convolutional neural networks (CNNs) extract features by sliding convolutional kernels across an image, focusing only on local information. By stacking multiple convolutional layers, CNNs can extract features at different levels of the input image layer by layer. This hierarchical feature extraction approach allows the model to better understand and process complex image data. However, simply stacking multiple convolutional layers cannot obtain global receptive field information. In visual tasks such as object detection, it cannot capture all information about objects (especially large objects), thus causing detection bias.

[0056] Therefore, current image feature extraction methods cannot achieve comprehensive extraction of all and local information, resulting in poor image feature extraction performance.

[0057] Please refer to Figure 1 , Figure 1 A flowchart illustrating a hybrid image feature extraction method combining convolution and self-attention, provided in an embodiment of the present invention. The method may include:

[0058] S101 processes the input image data using an N×N convolutional layer and a 1×1 convolutional layer to obtain convolutional processed data.

[0059] The execution subject of this embodiment can be any electronic device. This embodiment is not limited to a specific N×N convolutional layer. For example, the N×N convolutional layer in this embodiment can be a 3×3 convolutional layer; or the N×N convolutional layer in this embodiment can be a 6×6 convolutional layer.

[0060] S102, use the local self-attention module to extract local features from the input image data to obtain local features.

[0061] The local self-attention module in this embodiment is a neural network module used to extract local features of an image. By calculating the relationship between each pixel and other pixels in the input image, it captures local structural information in the image.

[0062] It should be further explained that, in order to improve the effect of image feature extraction, after extracting local features from the input image data using the local self-attention module, the method can further include: using an N×N convolutional layer to perform convolution processing on the local features and the fused data to obtain fused local data; correspondingly, fusing the global features and local features to obtain fused image features can include: fusing the global features and the fused local data to obtain fused image features. This embodiment, by performing convolution processing on the local features and the fused data to obtain fused local data, makes the information extraction more comprehensive, thereby improving the effect of image feature extraction.

[0063] It should be further explained that, in order to improve the effect of local feature extraction, the process of local feature extraction may include:

[0064] S1021, Perform window division operation on the input image data to obtain equal division data, and calculate the self-attention QKV matrix on each equal division data to obtain the corresponding target equal division data;

[0065] S1022, Perform reconstruction and restoration processing on the target equally divided data to obtain the reconstructed input image data;

[0066] S1023, the reconstructed input image data is divided into 3 parts, which are then fed into 3 fully connected layers with an output dimension of d for data calculation, respectively, to obtain feature matrices Q, K and V. These 3 feature matrices are then calculated according to the local self-attention formula. The local self-attention formula is used to characterize the relationship between the self-attention calculation result and d, Q, K and V. Q represents the query, K represents the key and V represents the value, which correspond to Q, K and V in the figure, respectively. d represents the output dimension of the fully connected layer.

[0067] In this embodiment, the local feature extraction has a larger receptive field than convolutional layers, which can compensate for the limited receptive field of convolutional layers. This allows the model to focus on more global image information. Compared to global feature extraction, it requires less computation. The global self-attention module performs QKV matrix calculation on the entire image, while the local self-attention module first divides the image into equal parts (if the image resolution cannot be divided equally, zero pixels are added around the image to make the length or width divisible by 2), and then performs QKV matrix calculation within these smaller blocks. This improves the effectiveness of local feature extraction.

[0068] S103 performs a fusion process on local features and convolutional data to obtain fused data.

[0069] It should be further explained that, in order to improve the fusion effect, the above-mentioned fusion processing of local features and convolutional processing data to obtain fused data can include: fusing local features and convolutional processing data to obtain initial fused data; and randomly shuffling the initial fused data to obtain the final fused data. This embodiment improves the fusion effect by breaking the model's comfort zone during training through random shuffling.

[0070] It should be further explained that, in order to improve the effect of fusing global and local features, after fusing the local features and convolutional processing data to obtain fused data, the method may further include: dividing the fused data into two parts to obtain first fused data and second fused data; accordingly, using a global self-attention module to extract global features from the fused data and the convolutional processing data to obtain global features; fusing the global features and the local features to obtain fused image features, which may include: using a global self-attention module to extract global features from the first fused data and the convolutional processing data to obtain global features; processing the local features and the second fused data using an N×N convolutional layer to obtain convolutional local features; and fusing the convolutional local features and global features to obtain fused image features. This embodiment divides the fused data into two parts, thereby fusing it with global and local features respectively, which improves the effect of fusing global and local features.

[0071] S104 utilizes the global self-attention module to extract global features from the fused data and the convolutionally processed data, thus obtaining global features.

[0072] The global self-attention module in this embodiment is a high-efficiency neural network component designed to improve the performance of deep networks in image processing tasks.

[0073] S105, fuses global and local features to obtain fused image features.

[0074] It should be further explained that, in order to reduce the number of channels, after fusing global and local features to obtain fused image features, the process can further include: using a 1×1 convolutional layer to process the fused image features to obtain the final fused image features. This embodiment uses a 1×1 convolutional layer to perform inter-channel interaction and dimensionality reduction (for example, if there are 64 feature maps after fusion, after dimensionality reduction by a 1×1 convolutional layer, 32 feature maps are obtained), thereby reducing the subsequent computational load.

[0075] It should be further explained that, in order to improve the accuracy of feature analysis, global features and local features are combined...

[0076] After fusing features to obtain fused image features, the process may further include: inputting the fused image features into an object detection model or a semantic segmentation model for feature analysis to obtain the object processing result. This embodiment improves the accuracy of feature analysis by performing feature analysis after cross-processing of global and local features.

[0077] This invention provides a hybrid image feature extraction method combining convolution and self-attention, comprising: S101, processing input image data using an N×N convolutional layer and a 1×1 convolutional layer to obtain convolutional processed data; S102, extracting local features from the input image data using a local self-attention module to obtain local features; S103, fusing the local features and the convolutional processed data to obtain fused data; S104, extracting global features from the fused data and the convolutional processed data using a global self-attention module to obtain global features; and S105, fusing the global features and local features to obtain fused image features. Compared to current methods that cannot simultaneously consider both local and global features, this application extracts features by cross-processing the input image data using both methods. This leverages the advantage of convolution in focusing on subtle local features while combining it with the ability of self-attention to capture long-range dependency information, thereby improving the image feature extraction effect. This approach maintains good stability in specific scenarios, such as industrial defect detection, where object scale changes significantly. Furthermore, this embodiment obtains fused local data by performing convolution processing on local features and fused data, resulting in more comprehensive information extraction and thus improving the image feature extraction effect. Moreover, the local feature extraction in this embodiment has a larger receptive field than convolutional layers, which can compensate for the limited receptive field of convolutional layers, allowing the model to focus on more global image information, while requiring less computation compared to global feature extraction. Furthermore, this embodiment breaks the model's comfort zone during training by performing random shuffling, thereby improving the fusion effect. Furthermore, this embodiment divides the fused data into two parts, fusing them separately with global and local features, improving the fusion effect of global and local features. Furthermore, this embodiment uses 1×1 convolutional layers for inter-channel interaction and performs dimensionality reduction to reduce subsequent computation. Finally, this embodiment performs feature analysis after cross-processing of global and local features, thereby improving the accuracy of feature analysis.

[0078] For a clearer understanding of this invention, please refer to the following details. Figure 2 , Figure 2 A flowchart illustrating a hybrid image feature extraction method combining convolution and self-attention, provided in this embodiment of the invention, may specifically include:

[0079] S201, input the input image data into path 1 and path 2 respectively.

[0080] This invention presents a hybrid image feature extraction method based on convolution and self-attention. This method combines local feature extraction via convolution with global feature extraction via self-attention. Image data is continuously cross-processed within the structure of this invention to extract potential information useful for the current task. This has significant semantic implications for improving the robustness of deep learning feature extraction models. For easier understanding, please refer to [link / reference]. Figure 3 , Figure 3 This is a schematic diagram of the overall structure for hybrid convolutional and self-attention image feature extraction provided in an embodiment of the present invention. This overall structure diagram corresponds to the hybrid convolutional and self-attention image feature extraction method. The input feature data in this embodiment can be one or more two-dimensional images, and the output is a set of feature maps after layers of feature extraction. This set of feature maps can be input into the decoder of an object detection or semantic segmentation model for final feature analysis to complete a specific visual task. In this embodiment, the input image data is input into path 1 and path 2 respectively.

[0081] S202, the data in path 1 will pass through a 3×3 convolutional layer, a 1×1 convolutional layer, and a 1×1 convolutional layer in sequence to obtain convolutional processing data, and then input the convolutional processing data into path 3 and path 5.

[0082] In this embodiment, the data in path 1 will pass through a convolutional layer with a convolutional window size of 3×3 (representing the length and width of the window), namely the 3×3conv in the figure, for the extraction of local features. The 1×1conv convolutional layer is used to integrate local information and the information interaction between channels (or multiple feature maps). The output of the 1×1conv convolutional layer will enter path 3 and path 5 respectively.

[0083] S203, the data in path 2 will enter a local self-attention block for feature extraction. After the local self-attention calculation is completed, the result will be input into path 4 and path 6.

[0084] In this embodiment, the data in path 2 enters a local self-attention block for feature extraction. The design of this module is primarily based on the following two points: 1. Compared to convolutional layers, the local self-attention module has a larger receptive field, which can compensate for the limited receptive field of convolutional layers, allowing the model to focus on more global image information; 2. Compared to the global self-attention module, the local self-attention module has less computational cost. The global self-attention module performs QKV matrix calculations on the entire image, while the local self-attention module first divides the image into four equal parts (if the image resolution cannot be divided into four equal parts, zero pixels are added around the image to ensure the image's length or width is divisible by 2), and then performs QKV matrix calculations within these four small blocks. The calculation process of the local self-attention block is as follows: Figure 4 As shown, Figure 4This is a flowchart illustrating a local self-attention block computation method provided in an embodiment of the present invention. The input first undergoes a window division operation, splitting the input into non-overlapping blocks A, B, C, and D. These four blocks are then subjected to self-attention QKV matrix calculations to obtain A', B', C', and D', respectively. Finally, A', B', C', and D' are... Figure 2 The positions are reorganized to resemble the input. The calculation process for self-attention is as follows: Figure 5 As shown, Figure 5 This is a flowchart illustrating a self-attention calculation process according to an embodiment of the present invention, where T represents transpose. The input is the split window data, which is then divided into three parts and fed into three fully connected layers (fully connected layer 1, fully connected layer 2, and fully connected layer 3) with an output dimension of d for data calculation, yielding feature matrices Q, K, and V respectively. These three feature matrices are then used to calculate the self-attention result according to the self-attention formula. The self-attention calculation formula characterizes the relationship between the self-attention calculation result and d, Q, K, and V, where Q represents the query, K represents the key, and V represents the value, corresponding to Q, K, and V in the diagram, and d represents the output dimension of the fully connected layer. In this invention, d is 64 (it can also be 32, 128, 356, etc.). After the local self-attention calculation is completed, the result is input to paths 4 and 6.

[0085] S204, the data from path 3 and path 4 will enter the channel splicing layer for data fusion, and the channels will be randomly shuffled. Then the result will be divided into two parts to obtain part_1 and part_2.

[0086] In this embodiment, the data from path 3 and path 4 will enter the channel splicing layer (or other data fusion methods) for data fusion. To reduce the risk of overfitting during model training and to prevent the model from being more biased towards data from convolutional or self-attention layers, this invention adds a channel random shuffling operation after the channel splicing layer to break the model's comfort zone during training. Then, the results are divided into two parts to obtain part_1 and part_2.

[0087] S205, the data from part_1 and the data from path 5 will be sent together into the global self-attention module for self-attention QKV calculation.

[0088] In this embodiment, the data from part_1 and the data from path 5 are sent together to the global self-attention module for self-attention QKV calculation. The global self-attention module is used here mainly to obtain global receptive field information, so that the model can mine global image features based on the information of the whole image.

[0089] S206, the data from part_2 will be fed together with the data from path 6 into a 3×3 convolutional layer for local information extraction.

[0090] In this embodiment, the data from part_2 and the data from path 6 are fed into a 3×3 convolutional layer for local information extraction. The input to the global self-attention block mainly comes from the data processed by the convolution, while the input to the second 3×3 convolutional layer mainly comes from the data processed by the self-attention layer. This method of cross-feature extraction helps to reduce the negative impact of the shortcomings of convolution and self-attention, while leveraging their respective advantages, thus combining the strengths of both methods.

[0091] S207, the results of the global self-attention module and the second 3×3 convolutional layer will be further fused by adding them pixel by pixel. The fused data will be incorporated into a 1×1 convolutional layer to perform inter-channel interaction and dimensionality reduction to reduce the number of channels, thus obtaining the feature extraction map.

[0092] In this embodiment, the results of the global self-attention module and the second 3×3 convolutional layer are further fused by adding them pixel by pixel. This result combines local microscopic information and global macroscopic information. The fused data is then incorporated into a 1×1 convolutional layer for channel interaction and dimensionality reduction (for example, if there are 64 feature maps after fusion, after dimensionality reduction by the 1×1 convolutional layer, 32 feature maps are obtained) to reduce the amount of subsequent computation.

[0093] S208, input the feature extraction map into the decoder of the object detection or semantic segmentation model for final feature analysis.

[0094] In this embodiment, the feature extraction map is used in the framework for object detection or semantic segmentation for decoding operations to complete specific visual tasks.

[0095] This invention provides an image feature extraction method that combines convolution and self-attention, offering the following advantages: better robustness and stronger feature extraction capability. The invention analyzes the respective advantages and disadvantages of convolution and self-attention mechanisms in current mainstream deep learning feature extraction methods. It extracts features by cross-processing image data using both methods, leveraging the advantage of convolution's focus on subtle local features while combining it with the ability of self-attention to capture long-range dependency information. This ensures good stability in specific scenarios, such as industrial defect detection, where object scale changes significantly.

[0096] The following describes the image feature extraction device that combines convolution and self-attention according to the embodiments of the present invention. The image feature extraction device that combines convolution and self-attention described below can be referred to in correspondence with the image feature extraction method that combines convolution and self-attention described above.

[0097] Please refer to the details. Figure 6 , Figure 6 A schematic diagram of a hybrid image feature extraction device combining convolution and self-attention, provided in an embodiment of the present invention, may include:

[0098] The convolution processing module 100 is used to process the input image data using N×N convolutional layers and 1×1 convolutional layers to obtain convolutional processed data;

[0099] The local feature extraction module 200 is used to extract local features from the input image data using a local self-attention module to obtain local features;

[0100] The information cross-processing module 300 is used to fuse the local features and the convolutional processing data to obtain fused data;

[0101] The global feature extraction module 400 is used to extract global features from the fused data and the convolutional processed data using the global self-attention module to obtain global features.

[0102] The local and global fusion module 500 is used to fuse the global features and the local features to obtain fused image features.

[0103] Furthermore, based on the above embodiments, the above-described convolutional and self-attention hybrid image feature extraction apparatus may further include:

[0104] The local data fusion determination module is used to perform convolution processing on the local features and the fused data using an N×N convolutional layer to obtain fused local data.

[0105] Accordingly, the local and global fusion module 500 may include:

[0106] The local and global fusion unit is used to fuse the global features and the fused local data to obtain the fused image features.

[0107] Furthermore, based on any of the above embodiments, the information cross-module 300 may include:

[0108] An initial fusion unit is used to fuse the local features and the convolutional processing data to obtain initial fused data;

[0109] A random shuffling processing unit is used to randomly shuffle the initial fused data to obtain the fused data.

[0110] Furthermore, based on any of the above embodiments, the above-described convolutional and self-attention hybrid image feature extraction apparatus may further include:

[0111] A partitioning module is used to divide the fused data into two parts to obtain first fused data and second fused data;

[0112] Correspondingly, the global feature extraction module 400 and the local and global fusion module 500 may include:

[0113] A global feature extraction unit is used to extract global features from the first fused data and the convolutional processed data using the global self-attention module to obtain the global features.

[0114] The convolutional local feature determination unit is used to process the local features and the second fused data using an N×N convolutional layer to obtain convolutional local features;

[0115] The fusion unit is used to fuse the convolutional local features and the global features to obtain the fused image features.

[0116] Furthermore, based on any of the above embodiments, the above-described convolutional and self-attention hybrid image feature extraction apparatus may further include:

[0117] The final fused image feature determination module is used to process the fused image features using a 1×1 convolutional layer to obtain the final fused image features.

[0118] Furthermore, based on any of the above embodiments, the local feature extraction module 200 may include:

[0119] The equal division processing unit is used to perform window equal division operation on the input image data to obtain equal division data, and to perform self-attention QKV matrix calculation on the equal division data to obtain the corresponding target equal division data.

[0120] The recombination unit is used to reconstruct and restore the target equally divided data to obtain reconstructed input image data.

[0121] The self-attention calculation unit is used to divide the recombined input image data into three parts, which are then fed into three fully connected layers with an output dimension of d for data calculation to obtain feature matrices Q, K, and V respectively. These three feature matrices are then calculated according to the local self-attention formula to obtain the local features.

[0122] Furthermore, based on any of the above embodiments, the above-described convolutional and self-attention hybrid image feature extraction apparatus may further include:

[0123] The feature analysis module is used to input the fused image features into the target detection model or semantic segmentation model for feature analysis to obtain the target processing result.

[0124] It should be noted that the order of the modules and units in the above-mentioned convolutional and self-attention hybrid image feature extraction device can be changed without affecting the logic.

[0125] The convolutional and self-attention hybrid image feature extraction device provided in this embodiment of the invention may include: a convolutional processing module 100, used to process input image data using N×N convolutional layers and 1×1 convolutional layers to obtain convolutional processed data; a local feature extraction module 200, used to extract local features from the input image data using a local self-attention module to obtain local features; an information cross-processing module 300, used to fuse the local features and the convolutional processed data to obtain fused data; a global feature extraction module 400, used to extract global features from the fused data and the convolutional processed data using a global self-attention module to obtain global features; and a local and global fusion module 500, used to fuse the global features and the local features to obtain fused image features. Compared to current methods that cannot simultaneously consider both local and global features, this application uses a cross-processing approach to extract features from input image data. This leverages the advantage of convolution in focusing on subtle local features while combining the ability of self-attention to capture long-range dependency information, thereby improving the image feature extraction effect. This approach can maintain good stability in certain scenarios, such as industrial defect detection, where the scale of objects varies greatly. Furthermore, this embodiment obtains fused local data by performing convolution processing on local features and fused data, resulting in more comprehensive information extraction and thus improving the image feature extraction effect. Moreover, the local feature extraction in this embodiment has a larger receptive field than convolutional layers, which can compensate for the limited receptive field of convolutional layers, allowing the model to focus on more global image information, while requiring less computation compared to global feature extraction. Furthermore, this embodiment breaks the model's comfort zone during training by performing random shuffling, thereby improving the fusion effect. Furthermore, this embodiment divides the fused data into two parts, fusing them separately with global and local features, improving the fusion effect of global and local features. Furthermore, this embodiment uses 1×1 convolutional layers for inter-channel interaction and performs dimensionality reduction to reduce subsequent computation. Finally, this embodiment performs feature analysis after cross-processing of global and local features, thereby improving the accuracy of feature analysis.

[0126] The following describes a hybrid image feature extraction device combining convolution and self-attention, provided by an embodiment of the present invention. The hybrid image feature extraction device described below can be referred to in correspondence with the hybrid image feature extraction method described above.

[0127] Please refer to Figure 7 , Figure 7 A schematic diagram of a hybrid image feature extraction device combining convolution and self-attention, provided in an embodiment of the present invention, may include:

[0128] Memory 10 is used to store computer programs;

[0129] Processor 20 is used to execute computer programs to implement the above-described convolutional and self-attention hybrid image feature extraction method.

[0130] The memory 10, processor 20, and communication interface 30 all communicate with each other through the communication bus 40.

[0131] In this embodiment of the invention, the memory 10 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment of the invention, the memory 10 may store programs for implementing the following functions:

[0132] The input image data is processed using N×N convolutional layers and 1×1 convolutional layers to obtain convolutional processed data;

[0133] The input image data is processed using a local self-attention module to extract local features, thus obtaining local features.

[0134] Local features and convolutional data are fused together to obtain fused data.

[0135] Global features are obtained by using a global self-attention module to extract global features from fused data and convolutionally processed data.

[0136] Global and local features are fused to obtain fused image features.

[0137] In one possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created during use.

[0138] Furthermore, memory 10 may include read-only memory and random access memory, providing instructions and data to the processor. A portion of the memory may also include NVRAM. The memory stores operating systems and operating instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and handling hardware-based tasks.

[0139] Processor 20 can be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic device. Processor 20 can be a microprocessor or any conventional processor. Processor 20 can call programs stored in memory 10.

[0140] The communication interface 30 can be an interface for the communication module, used to connect with other devices or systems.

[0141] Of course, it should be noted that, Figure 7 The structure shown does not constitute a limitation on the image feature extraction device combining convolution and self-attention in the embodiments of the present invention. In practical applications, the image feature extraction device combining convolution and self-attention can include more than Figure 7 More or fewer components as shown, or combinations of certain components.

[0142] The following describes the computer-readable storage medium provided in the embodiments of the present invention. The computer-readable storage medium described below can be referred to in correspondence with the image feature extraction method of convolution and self-attention hybrid described above.

[0143] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described method for extracting image features by combining convolution and self-attention.

[0144] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0145] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0146] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0147] Finally, it should be noted that in this document, relationships such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0148] The present invention provides a detailed description of a method, apparatus, and device for image feature extraction using a hybrid convolution and self-attention approach. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for image feature extraction combining convolution and self-attention, characterized in that, include: The input image data is processed using N×N convolutional layers and 1×1 convolutional layers to obtain convolutional processed data; The input image data is processed using a local self-attention module to extract local features, thus obtaining local features. The local features and the convolutional data are fused together to obtain initial fused data; The initial fused data is randomly shuffled to obtain the fused data; The fused data is divided into two parts to obtain the first fused data and the second fused data. The global self-attention module is used to extract global features from the first fused data and the convolutional processed data to obtain global features. The local features and the second fused data are processed using an N×N convolutional layer to obtain convolutional local features; The convolutional local features and the global features are fused to obtain fused image features.

2. The image feature extraction method combining convolution and self-attention according to claim 1, characterized in that, After fusing the global features and the local features to obtain the fused image features, the method further includes: The fused image features are processed using a 1×1 convolutional layer to obtain the final fused image features.

3. The image feature extraction method combining convolution and self-attention according to claim 1, characterized in that, The process of local feature extraction includes: The input image data is divided into equal parts by a window to obtain equal parts data. The self-attention QKV matrix is ​​calculated for each of the equal parts data to obtain the corresponding target equal parts data. The target equally divided data is reconstructed and restored to obtain reconstructed input image data; The reconstructed input image data is divided into three parts, which are then fed into three fully connected layers with an output dimension of d for data computation, respectively, to obtain feature matrices Q, K, and V. These three feature matrices are then used to calculate the local features according to the local self-attention formula.

4. The image feature extraction method combining convolution and self-attention according to claim 1, characterized in that, After fusing the global features and the local features to obtain the fused image features, the method further includes: The fused image features are input into a target detection model or a semantic segmentation model for feature analysis to obtain the target processing result.

5. A hybrid image feature extraction device combining convolution and self-attention, characterized in that, The image feature extraction method based on any one of claims 1 to 4, comprising: The convolution processing module is used to process the input image data using N×N convolutional layers and 1×1 convolutional layers to obtain convolutional processed data; The local feature extraction module is used to extract local features from the input image data using the local self-attention module to obtain local features; The information cross-processing module is used to fuse the local features and the convolutional processing data to obtain fused data; A global feature extraction module is used to extract global features from the fused data and the convolutional processed data using a global self-attention module to obtain global features. The local and global fusion module is used to fuse the global features and the local features to obtain fused image features.

6. A hybrid image feature extraction device combining convolution and self-attention, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the convolutional and self-attention hybrid image feature extraction method as described in any one of claims 1 to 4 when executing the computer program.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the convolutional and self-attention hybrid image feature extraction method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Dual most correlation recommendation method and device, equipment and storage medium

    CN114138967A

  • Medical image automatic segmentation method of U-shaped network based on fusion convolution and attention mechanism

    CN117474866A