Feature extraction method and device, electronic equipment and storage medium
By combining channel and spatial attention feature extraction models in the feature extraction model, and using weighted distance and product feature fusion algorithms to determine self-attention parameters, the problem of insufficient image feature accuracy in existing technologies is solved, and higher-precision feature extraction is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING QIYI CENTURY SCI & TECH CO LTD
- Filing Date
- 2022-12-16
- Publication Date
- 2026-04-21
AI Technical Summary
Existing self-attention feature extraction methods cannot fully determine the self-attention parameters of each dimension of an image feature, resulting in low image feature accuracy.
By inputting the feature maps into the channel attention feature extraction model and the spatial attention feature extraction model respectively, the channel attention features and spatial attention features are fused using the weighted distance feature fusion algorithm and the weighted product feature fusion algorithm to determine the self-attention parameters.
It improves the accuracy of feature extraction, achieving more precise feature extraction.
Smart Images

Figure CN116012684B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a feature extraction method, apparatus, electronic device and storage medium. Background Technology
[0002] In deep learning convolutional neural networks, a feature extraction model often contains many layers (such as convolutional layers, fully connected layers, pooling layers, etc.). By stacking multiple layers, features of the input image (speech and other inputs) can be extracted layer by layer to achieve the final task objective (such as classification, regression, etc.).
[0003] With technological advancements, researchers have proposed attention mechanisms to incorporate into network models in order to achieve task objectives with greater precision. Attention originates from the human visual system. When humans observe the outside world, they generally do not view things as a whole, but tend to selectively acquire certain important parts of the observed object based on the needs of the task. Taking the human face as an example, when we need to know the position of the eyes, we focus more on the eye area and automatically ignore other areas of the face such as the nose, mouth, forehead, and hair. This is because, compared to information about the eye position, information about other parts is considered distracting or background information.
[0004] Similarly, self-attention mechanisms can help the model assign different weights to each part of the input, extract more critical and important information, and enable the model to make more accurate judgments.
[0005] However, existing self-attention feature extraction methods generally perform attention feature extraction on the channels of the feature map or on the spatial location of the feature map. They cannot comprehensively determine the self-attention parameters of each dimension of the image features, resulting in low feature accuracy of the extracted image. Summary of the Invention
[0006] In view of this, in order to solve the technical problem that existing self-attention feature extraction methods cannot fully determine the self-attention parameters of each dimension of image features, resulting in low feature accuracy of the extracted image, embodiments of the present invention provide a feature extraction method, apparatus, electronic device and storage medium.
[0007] In a first aspect, embodiments of the present invention provide a feature extraction method, the method comprising:
[0008] Extract feature maps from the target image;
[0009] The feature maps are input into the trained channel attention feature extraction model and spatial attention feature extraction model, respectively, to obtain the channel attention features and spatial attention features of the target image;
[0010] The channel attention features and the spatial attention features are fused using a preset weighted distance feature fusion algorithm and a weighted product feature fusion algorithm, respectively, to obtain weighted distance fusion features and weighted product fusion features;
[0011] Based on the weighted distance fusion feature and the weighted product fusion feature, the self-attention parameters are determined;
[0012] Based on the feature map and the self-attention parameters, the self-attention features of the target image are determined.
[0013] As a possible implementation, a preset weighted distance feature fusion algorithm is used to fuse the channel attention features and the spatial attention features to obtain weighted distance fused features, including:
[0014] Determine the first weight value corresponding to the channel attention feature, and determine the second weight value corresponding to the spatial attention feature;
[0015] Multiply the channel attention feature by the first weight value to obtain the first product, and multiply the spatial attention feature by the second weight value to obtain the second product;
[0016] Determine the sum of the squares of the first product and the second product;
[0017] The weighted distance fusion feature is obtained by taking the square root of the sum of squares.
[0018] As a possible implementation, a pre-defined weighted product feature fusion algorithm is used to fuse the channel attention features and the spatial attention features to obtain weighted product fused features, including:
[0019] Determine the weight values for the product feature fusion;
[0020] The channel attention feature, the spatial attention feature, and the product feature fusion weight value are multiplied together to obtain the weighted product fusion feature.
[0021] As one possible implementation, determining the self-attention parameters based on the weighted distance fusion features and the weighted product fusion features includes:
[0022] The self-attention parameters are obtained by summing the weighted distance fusion features and the weighted product fusion features.
[0023] Alternatively, the weighted distance fusion feature and the weighted product fusion feature can be summed in weights to obtain the self-attention parameters.
[0024] As one possible implementation, the channel attention feature extraction model includes a global average pooling layer, a global max pooling layer, a fusion layer, a fully connected layer, and a Sigmoid operator; the feature map is input into the trained channel attention feature extraction model to obtain the channel attention features of the target image, including:
[0025] The feature map is input into the trained channel attention feature extraction model. The global average pooling layer performs global average feature extraction on the feature map to obtain average channel features, and the global max pooling layer performs global max feature extraction on the feature map to obtain maximum channel features. The fusion layer fuses the average channel features and the maximum channel features to obtain fused features. The fully connected layer and the Sigmoid operator process the fused features sequentially to obtain the channel attention features of the target image.
[0026] As one possible implementation, the fusion layer fuses the average channel feature and the maximum channel feature to obtain fused features in the following manner:
[0027] Determine the third weight value corresponding to the average channel feature and the fourth weight value corresponding to the maximum channel feature;
[0028] The average channel feature is multiplied by the third weight value to obtain the third product, and the maximum channel feature is multiplied by the fourth weight value to obtain the fourth product;
[0029] The third product and the fourth product are summed to obtain the fusion feature.
[0030] As one possible implementation, the spatial attention feature extraction model includes convolutional layers, a softmax operator, and a reshape operator.
[0031] Secondly, embodiments of the present invention provide a feature extraction apparatus, the apparatus comprising:
[0032] The extraction module is used to extract feature maps from the target image;
[0033] The input module is used to input the feature map into the trained channel attention feature extraction model and spatial attention feature extraction model respectively to obtain the channel attention features and spatial attention features of the target image;
[0034] The feature fusion module is used to fuse the channel attention features and the spatial attention features using a preset weighted distance feature fusion algorithm and a weighted product fusion algorithm, respectively, to obtain weighted distance fusion features and weighted product fusion features;
[0035] The first determining module is used to determine the self-attention parameters based on the weighted distance fusion features and the weighted product fusion features;
[0036] The second determining module is used to determine the self-attention features of the target image based on the feature map and the self-attention parameters.
[0037] As one possible implementation, the feature fusion module is specifically used for:
[0038] Determine the first weight value corresponding to the channel attention feature, and determine the second weight value corresponding to the spatial attention feature;
[0039] Multiply the channel attention feature by the first weight value to obtain the first product, and multiply the spatial attention feature by the second weight value to obtain the second product;
[0040] Determine the sum of the squares of the first product and the second product;
[0041] The weighted distance fusion feature is obtained by taking the square root of the sum of squares.
[0042] As one possible implementation, the feature fusion module is specifically used for:
[0043] Determine the weight values for the product feature fusion;
[0044] The channel attention feature, the spatial attention feature, and the product feature fusion weight value are multiplied together to obtain the weighted product fusion feature.
[0045] As one possible implementation, the first determining module is specifically used for:
[0046] The self-attention parameters are obtained by summing the weighted distance fusion features and the weighted product fusion features.
[0047] Alternatively, the weighted distance fusion feature and the weighted product fusion feature can be summed in weights to obtain the self-attention parameters.
[0048] As one possible implementation, the channel attention feature extraction model includes a global average pooling layer, a global max pooling layer, a fusion layer, a fully connected layer, and a Sigmoid operator; the feature map is input into the trained channel attention feature extraction model to obtain the channel attention features of the target image, including:
[0049] The feature map is input into the trained channel attention feature extraction model. The global average pooling layer performs global average feature extraction on the feature map to obtain average channel features, and the global max pooling layer performs global max feature extraction on the feature map to obtain maximum channel features. The fusion layer fuses the average channel features and the maximum channel features to obtain fused features. The fully connected layer and the Sigmoid operator process the fused features sequentially to obtain the channel attention features of the target image.
[0050] As one possible implementation, the fusion layer fuses the average channel feature and the maximum channel feature to obtain fused features in the following manner:
[0051] Determine the third weight value corresponding to the average channel feature and the fourth weight value corresponding to the maximum channel feature;
[0052] The average channel feature is multiplied by the third weight value to obtain the third product, and the maximum channel feature is multiplied by the fourth weight value to obtain the fourth product;
[0053] The third product and the fourth product are summed to obtain the fusion feature.
[0054] As one possible implementation, the spatial attention feature extraction model includes convolutional layers, a softmax operator, and a reshape operator.
[0055] Thirdly, embodiments of the present invention provide an electronic device, including: a processor and a memory, wherein the processor is configured to execute a feature extraction program stored in the memory to implement the feature extraction method described in any one of the first aspects.
[0056] Fourthly, embodiments of the present invention provide a storage medium storing one or more programs, which can be executed by one or more processors to implement the feature extraction method described in any one aspect.
[0057] The technical solution provided in this invention extracts feature maps from a target image and inputs these feature maps into a trained channel attention feature extraction model and a spatial attention feature extraction model, respectively, to obtain channel attention features and spatial attention features of the target image. Then, using a preset weighted distance feature fusion algorithm and a weighted product feature fusion algorithm, the channel attention features and spatial attention features are fused to obtain weighted distance fusion features and weighted product fusion features, respectively. Based on these weighted distance fusion features and weighted product fusion features, self-attention parameters are determined. This technical solution, by extracting both channel attention features and spatial attention features from the target image's feature map during feature extraction, and determining self-attention parameters based on both dimensions of attention features, and then determining the target image's self-attention features based on the feature map and self-attention parameters, achieves more accurate feature extraction compared to extracting features from only one dimension of attention features, either channel attention features or spatial attention features, thus improving the accuracy of feature extraction. Attached Figure Description
[0058] Figure 1 A flowchart illustrating an embodiment of a feature extraction method provided by this invention;
[0059] Figure 2 A schematic diagram of a channel attention feature extraction model provided in an embodiment of the present invention;
[0060] Figure 3 A schematic diagram of a spatial attention feature extraction model provided in an embodiment of the present invention;
[0061] Figure 4 A flowchart illustrating an embodiment of another feature extraction method provided by this invention;
[0062] Figure 5 A block diagram illustrating an embodiment of a feature extraction device provided by this invention;
[0063] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0064] 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, 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.
[0065] The feature extraction method provided by the present invention will be further explained and described below with reference to the accompanying drawings and specific embodiments. The embodiments do not constitute a limitation on the embodiments of the present invention.
[0066] See Figure 1 This is a flowchart illustrating an embodiment of a feature extraction method provided by the present invention. Figure 1 As shown, the process may include the following steps:
[0067] Step 101: Extract the feature map of the target image.
[0068] The target image mentioned above is an image of the object whose features are to be extracted.
[0069] The aforementioned feature map may include global features of the target image or local features of the target image; this embodiment of the invention does not impose any limitations on this.
[0070] In one embodiment, the execution subject of this invention may be a feature extraction model. When the model receives an input target image, it can extract the feature map of the target image through a preset feature extraction module. The feature extraction module may be a basic network layer, including but not limited to: convolutional layers, fully connected layers, and pooling layers.
[0071] Step 102: Input the feature maps into the trained channel attention feature extraction model and spatial attention feature extraction model respectively to obtain the channel attention features and spatial attention features of the target image.
[0072] In this embodiment of the invention, to improve the accuracy of feature extraction, a self-attention feature extraction module can be added to the feature extraction model. This self-attention feature extraction module applies self-attention mechanisms. Attention originates from the human visual system. When humans observe external objects, they generally do not view them as a whole, but tend to selectively acquire certain important parts of the observed objects according to the needs of the task objective.
[0073] For example, in facial observation applications, when we need to know the position of the eyes, we will focus more on the eye area and automatically ignore other areas of the face such as the nose, mouth, forehead, and hair. This is because, compared to the information about the eye position, information about other parts of the face is interference information or background information.
[0074] Similarly, self-attention mechanisms can help the model assign different weights to each part of the input, extract more critical and important information, and enable the model to make more accurate judgments without increasing the computational and storage overhead of the model.
[0075] Based on this, the execution subject of this embodiment of the invention improves the accuracy of feature extraction by extracting channel attention features and spatial attention features from the feature map.
[0076] Specifically, the aforementioned feature maps can be input into the trained channel attention feature extraction model and spatial attention feature extraction model, respectively, to obtain the channel attention features and spatial attention features of the target image.
[0077] In one embodiment, the channel attention feature extraction model described above may include a global average pooling layer, a global max pooling layer, a fusion layer, a fully connected layer, and a Sigmoid operator.
[0078] Based on this, the execution entity of this embodiment can input the feature map into the trained channel attention feature extraction model, so that the global average pooling layer can perform global average feature extraction on the feature map to obtain average channel features. Then, the global max pooling layer can perform global max feature extraction on the feature map to obtain maximum channel features. Finally, the fusion layer can fuse the average channel features and the maximum channel features to obtain fused features.
[0079] Optionally, when fusing the average channel features and the maximum channel features in the fusion layer, the third weight value corresponding to the average channel features and the fourth weight value corresponding to the maximum channel features can be determined first. Then, the average channel features are multiplied by the third weight value to obtain the third product, and the maximum channel features are multiplied by the fourth weight value to obtain the fourth product. Finally, the third product and the fourth product can be summed to obtain the fused features.
[0080] Subsequently, the aforementioned fully connected layer and the aforementioned Sigmod operator can be used to process the fused features sequentially to obtain the channel attention features of the target image.
[0081] For example, see Figure 2 This is a schematic diagram of a channel attention feature extraction model provided in an embodiment of the present invention. Figure 2 As shown, the channel attention feature extraction model may include a global average pooling layer, a global max pooling layer, a fusion layer, a fully connected layer, and a Sigmoid operator.
[0082] Suppose the input feature I (i.e., feature map) is (B, H, W, C), where B represents the number of images (batch), H and W represent the width and height of the feature map, and C represents the number of channels in the feature map. The specific process is as follows:
[0083] Step (1): Input feature I first undergoes one global average pooling and one global max pooling in parallel.
[0084] Step (2): The fusion layer directly performs feature fusion on the two features output by the global average pooling and global max pooling, and the output feature dimension is (B, 1, 1, C).
[0085] Step (3): The output features of step (2) are passed through a fully connected layer and a sigmoid operator to obtain the final channel attention features ca, with dimensions (B, 1, 1, C).
[0086] In one embodiment, the spatial attention feature extraction model described above may include a convolutional layer Softmax operator and a Reshape operator.
[0087] Based on this, the execution subject of this embodiment of the invention can input the feature map into the above-trained spatial attention feature extraction model, so that the feature map is processed by the above-mentioned convolutional layer, activated by the above-mentioned Softmax operator, and transformed by the above-mentioned Reshape operator, thereby obtaining the spatial attention features of the target image.
[0088] For example, see Figure 3 This is a schematic diagram of a spatial attention feature extraction model provided in an embodiment of the present invention. Figure 3 As shown, the spatial attention feature extraction model may include a 1*1 convolutional layer, a Softmax operator, and a Reshape operator.
[0089] Suppose the input feature I (i.e., feature map) is (B, H, W, C), where B represents the number of images (batch), H and W represent the width and height of the feature map, and C represents the number of channels in the feature map. The specific process is as follows:
[0090] Step (1): Input feature I first goes through a 1*1 convolution, and the output feature dimension is (B, H, W, 1). The 1*1 convolution will modify the number of channels C to 1.
[0091] Step (2): The output features from step (1) are processed by a softmax operator, and the output feature dimensions are (B, H, W, 1).
[0092] Step (3): After passing through the reshape operator, the shape of the input feature is modified to obtain the final spatial attention feature sa with dimensions (B, H, W, C).
[0093] Step 103: Use the preset weighted distance feature fusion algorithm and weighted product feature fusion algorithm to perform feature fusion on channel attention features and spatial attention features respectively, to obtain weighted distance fusion features and weighted product fusion features.
[0094] Step 104: Determine the self-attention parameters based on the weighted distance fusion features and the weighted product fusion features.
[0095] The following provides a unified explanation of steps 103 and 104:
[0096] In this embodiment of the invention, in order to improve the accuracy of feature extraction, a self-attention mechanism can be added to the feature model, and the channel attention features and spatial attention features of the feature map can be determined respectively. The channel attention features and spatial attention features are then fused to obtain the self-attention parameters corresponding to the feature map.
[0097] Optionally, a preset weighted distance feature fusion algorithm can be used to fuse channel attention features and spatial attention features to obtain weighted distance fused features.
[0098] Specifically, the first weight value corresponding to the channel attention feature and the second weight value corresponding to the spatial attention feature can be determined. Then, the channel attention feature is multiplied by the first weight value to obtain the first product, and the spatial attention feature is multiplied by the second weight value to obtain the second product. Next, the sum of squares of the first and second products can be determined, and the square root of this sum is taken to obtain the weighted distance fusion feature. To facilitate understanding of the calculation process of the above weighted distance fusion feature, the formula for the weighted distance feature fusion algorithm is shown below, specifically, as shown in equation (I):
[0099]
[0100] Wherein, W1 is the weighted distance fusion feature mentioned above, w1 is the first weight value, w2 is the second weight value, ca is the channel attention feature, and sa is the spatial attention feature.
[0101] Optionally, the first and second weight values mentioned above are obtained by training the feature extraction model based on the target features to be extracted from the target image.
[0102] Meanwhile, using a pre-defined weighted product feature fusion algorithm, channel attention features and spatial attention features are fused to obtain weighted product fused features.
[0103] Specifically, the weight values for product feature fusion can be determined first. Then, the channel attention features, spatial attention features, and product feature fusion weight values mentioned above can be multiplied together to obtain the weighted product fusion feature. To facilitate understanding of the calculation process of the weighted product fusion feature, the formula for the weighted product feature fusion algorithm is shown below, specifically, as shown in equation (II):
[0104] W2=w3*ca*sa formula (2)
[0105] Wherein, W2 is the aforementioned weighted product fusion feature, w3 is the product feature fusion weight value, ca is the channel attention feature, and sa is the spatial attention feature.
[0106] Optionally, the aforementioned third weight value is obtained by training the feature extraction model based on the target features to be extracted from the target image during training.
[0107] In one embodiment, the sum of the weighted distance fusion feature and the weighted product fusion feature can be determined as the self-attention parameter of the feature map.
[0108] In another embodiment, the weighted distance fusion features and the weighted product fusion features can be summed to obtain the self-attention parameters of the feature map.
[0109] Step 105: Based on the above feature map and self-attention parameters, determine the self-attention features of the target image.
[0110] The feature map mentioned above may include global or local features of the target image.
[0111] In this embodiment of the invention, in order to determine the key features in the feature map, the global or local features included in the feature map can be multiplied by the self-attention parameter corresponding to the feature map to obtain the self-attention features of the target image.
[0112] The technical solution provided in this invention extracts feature maps from a target image and inputs these feature maps into a trained channel attention feature extraction model and a spatial attention feature extraction model, respectively, to obtain channel attention features and spatial attention features of the target image. Then, using a preset weighted distance feature fusion algorithm and a weighted product feature fusion algorithm, the channel attention features and spatial attention features are fused to obtain weighted distance fusion features and weighted product fusion features, respectively. Based on these weighted distance fusion features and weighted product fusion features, self-attention parameters are determined. This technical solution, by extracting both channel attention features and spatial attention features from the target image's feature map during feature extraction, and determining self-attention parameters based on both dimensions of attention features, and then determining the target image's self-attention features based on the feature map and self-attention parameters, achieves more accurate feature extraction compared to extracting features from only one dimension of attention features, either channel attention features or spatial attention features, thus improving the accuracy of feature extraction.
[0113] See Figure 4 This is a flowchart illustrating an embodiment of another feature extraction method provided by the present invention. Figure 4 As shown, the process may include the following:
[0114] In this embodiment of the invention, the executing entity can determine the channel attention features and spatial attention features of the input feature I through the channel attention feature extraction model in the channel attention module C and the spatial attention feature extraction model in the spatial attention module S, respectively.
[0115] Subsequently, by fusing the channel attention features and spatial attention features, self-attention parameters can be obtained. These parameters can be obtained by inputting the channel attention features and spatial attention features into the feature fusion formula shown in equation (iii). Then, by multiplying the input feature I by the self-attention parameters, the self-attention features of the target image can be obtained.
[0116]
[0117] Where w is the self-attention parameter, w1, w2, and w3 are preset parameters, ca is the channel attention feature, and sa is the spatial attention feature.
[0118] The technical solution provided by this invention determines the channel attention features and spatial attention features of input feature I through the channel attention feature extraction model in channel attention module C and the spatial attention feature extraction model in spatial attention module S, respectively. By fusing the channel attention features and spatial attention features, self-attention parameters are obtained. Then, the input feature I is multiplied by these self-attention parameters to obtain the self-attention features of the target image. This technical solution, by extracting the channel attention features and spatial attention features of the target image's feature map during feature extraction, and determining the self-attention parameters based on these two dimensions of attention features, and then determining the self-attention features of the target image based on the feature map and self-attention parameters, achieves more accurate feature extraction and improves the precision of feature extraction compared to extracting features from a single dimension of attention features, either channel or spatial.
[0119] See Figure 5 This is a block diagram illustrating an embodiment of a feature extraction device provided by an embodiment of the present invention. Figure 5 As shown, the device includes:
[0120] Extraction module 51 is used to extract feature maps of the target image;
[0121] Input module 52 is used to input the feature map into the trained channel attention feature extraction model and spatial attention feature extraction model respectively to obtain the channel attention features and spatial attention features of the target image;
[0122] The feature fusion module 53 is used to perform feature fusion on the channel attention features and the spatial attention features using a preset weighted distance feature fusion algorithm and a weighted product fusion algorithm, respectively, to obtain weighted distance fusion features and weighted product fusion features;
[0123] The first determining module 54 is used to determine the self-attention parameters based on the weighted distance fusion features and the weighted product fusion features;
[0124] The second determining module 55 is used to determine the self-attention features of the target image based on the feature map and the self-attention parameters.
[0125] As one possible implementation, the feature fusion module 53 is specifically used for:
[0126] Determine the first weight value corresponding to the channel attention feature, and determine the second weight value corresponding to the spatial attention feature;
[0127] Multiply the channel attention feature by the first weight value to obtain the first product, and multiply the spatial attention feature by the second weight value to obtain the second product;
[0128] Determine the sum of the squares of the first product and the second product;
[0129] The weighted distance fusion feature is obtained by taking the square root of the sum of squares.
[0130] As one possible implementation, the feature fusion module 53 is specifically used for:
[0131] Determine the weight values for the product feature fusion;
[0132] The channel attention feature, the spatial attention feature, and the product feature fusion weight value are multiplied together to obtain the weighted product fusion feature.
[0133] As one possible implementation, the first determining module 54 is specifically used for:
[0134] The self-attention parameters are obtained by summing the weighted distance fusion features and the weighted product fusion features.
[0135] Alternatively, the weighted distance fusion feature and the weighted product fusion feature can be summed in weights to obtain the self-attention parameters.
[0136] As one possible implementation, the channel attention feature extraction model includes a global average pooling layer, a global max pooling layer, a fusion layer, a fully connected layer, and a Sigmoid operator; the feature map is input into the trained channel attention feature extraction model to obtain the channel attention features of the target image, including:
[0137] The feature map is input into the trained channel attention feature extraction model. The global average pooling layer performs global average feature extraction on the feature map to obtain average channel features, and the global max pooling layer performs global max feature extraction on the feature map to obtain maximum channel features. The fusion layer fuses the average channel features and the maximum channel features to obtain fused features. The fully connected layer and the Sigmoid operator process the fused features sequentially to obtain the channel attention features of the target image.
[0138] As one possible implementation, the fusion layer fuses the average channel feature and the maximum channel feature to obtain fused features in the following manner:
[0139] Determine the third weight value corresponding to the average channel feature and the fourth weight value corresponding to the maximum channel feature;
[0140] The average channel feature is multiplied by the third weight value to obtain the third product, and the maximum channel feature is multiplied by the fourth weight value to obtain the fourth product;
[0141] The third product and the fourth product are summed to obtain the fusion feature.
[0142] As one possible implementation, the spatial attention feature extraction model includes convolutional layers, a softmax operator, and a reshape operator.
[0143] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Figure 6 The illustrated electronic device 600 includes at least one processor 601, a memory 602, at least one network interface 604, and a user interface 603. The various components in the electronic device 600 are coupled together via a bus system 605. It is understood that the bus system 605 is used to implement communication between these components. In addition to a data bus, the bus system 605 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in… Figure 6 The general designated all buses as Bus System 605.
[0144] The user interface 603 may include a display, keyboard, or clicking device (e.g., mouse, trackball, touchpad, or touchscreen).
[0145] It is understood that the memory 602 in this embodiment of the invention can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate Synchronous DRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 602 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0146] In some implementations, memory 602 stores elements, executable units or data structures, or subsets thereof, or extended sets thereof: operating system 6021 and application program 6022.
[0147] The operating system 6021 includes various system programs, such as the framework layer, core library layer, and driver layer, used to implement various basic business functions and handle hardware-based tasks. The application program 6022 includes various applications, such as a media player and a browser, used to implement various application functions. The program implementing the method of this embodiment can be included in the application program 6022.
[0148] In this embodiment of the invention, by calling the program or instructions stored in the memory 602, specifically the program or instructions stored in the application program 6022, the processor 601 executes the method steps provided in each method embodiment, including, for example:
[0149] Extract feature maps from the target image;
[0150] The feature maps are input into the trained channel attention feature extraction model and spatial attention feature extraction model, respectively, to obtain the channel attention features and spatial attention features of the target image;
[0151] The channel attention features and the spatial attention features are fused using a preset weighted distance feature fusion algorithm and a weighted product feature fusion algorithm, respectively, to obtain weighted distance fusion features and weighted product fusion features;
[0152] Based on the weighted distance fusion feature and the weighted product fusion feature, the self-attention parameters are determined;
[0153] Based on the feature map and the self-attention parameters, the self-attention features of the target image are determined.
[0154] The methods disclosed in the above embodiments of the present invention can be applied to processor 601, or implemented by processor 601. Processor 601 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 601 or by instructions in the form of software. The processor 601 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the present invention can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software units in the decoding processor. The software units may be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 602. Processor 601 reads the information in memory 602 and, in conjunction with its hardware, completes the steps of the above method.
[0155] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.
[0156] For software implementation, the techniques described herein can be implemented by units that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.
[0157] The electronic device provided in this embodiment may be as follows: Figure 6 The electronic device shown can perform the following: Figure 1 and Figure 2 All steps of the feature extraction method are then implemented to achieve... Figure 1 and Figure 2 For details on the technical effectiveness of the feature extraction method shown, please refer to [link / reference]. Figure 1 and Figure 2 The relevant descriptions are presented concisely and will not be elaborated upon here.
[0158] This invention also provides a storage medium (computer-readable storage medium). This storage medium stores one or more programs. The storage medium may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk, or solid-state drive; the memory may also include combinations of the above types of memory.
[0159] When one or more programs in the storage medium can be executed by one or more processors to implement the feature extraction method described above that is executed on the electronic device side.
[0160] The processor is used to execute a feature extraction program stored in the memory to implement the following steps of a feature extraction method executed on the electronic device side:
[0161] Extract feature maps from the target image;
[0162] The feature maps are input into the trained channel attention feature extraction model and spatial attention feature extraction model, respectively, to obtain the channel attention features and spatial attention features of the target image;
[0163] The channel attention features and the spatial attention features are fused using a preset weighted distance feature fusion algorithm and a weighted product feature fusion algorithm, respectively, to obtain weighted distance fusion features and weighted product fusion features;
[0164] Based on the weighted distance fusion feature and the weighted product fusion feature, the self-attention parameters are determined;
[0165] Based on the feature map and the self-attention parameters, the self-attention features of the target image are determined.
[0166] 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.
[0167] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0168] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A feature extraction method, characterized in that, The method includes: Extract feature maps from the target image; The feature maps are input into the trained channel attention feature extraction model and spatial attention feature extraction model, respectively, to obtain the channel attention features and spatial attention features of the target image; The channel attention features and the spatial attention features are fused using a preset weighted distance feature fusion algorithm and a weighted product feature fusion algorithm, respectively, to obtain weighted distance fusion features and weighted product fusion features; Based on the weighted distance fusion feature and the weighted product fusion feature, the self-attention parameters are determined; Based on the feature map and the self-attention parameters, the self-attention features of the target image are determined; The method involves fusing the channel attention features and the spatial attention features using a preset weighted distance feature fusion algorithm to obtain weighted distance fusion features. This includes: determining a first weight value corresponding to the channel attention features and a second weight value corresponding to the spatial attention features; multiplying the channel attention features by the first weight value to obtain a first product, and multiplying the spatial attention features by the second weight value to obtain a second product; determining the sum of squares of the first product and the second product; and performing a square root operation on the sum of squares to obtain the weighted distance fusion features. The method involves fusing the channel attention features and the spatial attention features using a preset weighted product feature fusion algorithm to obtain weighted product fusion features, including: determining the product feature fusion weight value; and multiplying the channel attention features, the spatial attention features, and the product feature fusion weight value to obtain the weighted product fusion features.
2. The method according to claim 1, characterized in that, The step of determining self-attention parameters based on the weighted distance fusion feature and the weighted product fusion feature includes: The self-attention parameters are obtained by summing the weighted distance fusion features and the weighted product fusion features. Alternatively, the weighted distance fusion feature and the weighted product fusion feature can be summed in weights to obtain the self-attention parameters.
3. The method according to claim 1, characterized in that, The channel attention feature extraction model includes a global average pooling layer, a global max pooling layer, a fusion layer, a fully connected layer, and a Sigmoid operator; The feature map is input into a trained channel attention feature extraction model to obtain the channel attention features of the target image, including: The feature map is input into the trained channel attention feature extraction model. The global average pooling layer performs global average feature extraction on the feature map to obtain average channel features, and the global max pooling layer performs global max feature extraction on the feature map to obtain maximum channel features. The fusion layer fuses the average channel features and the maximum channel features to obtain fused features. The fully connected layer and the Sigmoid operator process the fused features sequentially to obtain the channel attention features of the target image.
4. The method according to claim 3, characterized in that, The fusion layer fuses the average channel feature and the maximum channel feature to obtain the fused feature in the following manner: Determine the third weight value corresponding to the average channel feature and the fourth weight value corresponding to the maximum channel feature; The average channel feature is multiplied by the third weight value to obtain the third product, and the maximum channel feature is multiplied by the fourth weight value to obtain the fourth product; The third product and the fourth product are summed to obtain the fusion feature.
5. The method according to claim 1, characterized in that, The spatial attention feature extraction model includes convolutional layers, a softmax operator, and a reshape operator.
6. A feature extraction device, characterized in that, The device includes: The extraction module is used to extract feature maps from the target image; The input module is used to input the feature map into the trained channel attention feature extraction model and spatial attention feature extraction model respectively to obtain the channel attention features and spatial attention features of the target image; The feature fusion module is used to fuse the channel attention features and the spatial attention features using a preset weighted distance feature fusion algorithm and a weighted product fusion algorithm, respectively, to obtain weighted distance fusion features and weighted product fusion features; The first determining module is used to determine the self-attention parameters based on the weighted distance fusion features and the weighted product fusion features; The second determining module is used to determine the self-attention features of the target image based on the feature map and the self-attention parameters; The method involves fusing the channel attention features and the spatial attention features using a preset weighted distance feature fusion algorithm to obtain weighted distance fusion features. This includes: determining a first weight value corresponding to the channel attention features and a second weight value corresponding to the spatial attention features; multiplying the channel attention features by the first weight value to obtain a first product, and multiplying the spatial attention features by the second weight value to obtain a second product; determining the sum of squares of the first product and the second product; and performing a square root operation on the sum of squares to obtain the weighted distance fusion features. The method involves fusing the channel attention features and the spatial attention features using a preset weighted product feature fusion algorithm to obtain weighted product fusion features, including: determining the product feature fusion weight value; and multiplying the channel attention features, the spatial attention features, and the product feature fusion weight value to obtain the weighted product fusion features.
7. An electronic device, characterized in that, include: A processor and a memory, the processor being configured to execute a feature extraction program stored in the memory to implement the feature extraction method according to any one of claims 1 to 5.
8. A storage medium, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement the feature extraction method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Remote sensing image super-resolution reconstruction method based on self-attention fusion
CN112712488A
Global self-attention target detection method combining channel space attention
CN114519807A