Self-attention spatial pyramid pooling method based on hybrid pooling and related components

By combining maximum pooling and average pooling, and using the self-attention model to expand the receptive field, the problems of insufficient feature extraction and insufficient receptive field expansion in visual analysis are solved, and the performance and accuracy of visual analysis are improved.

CN118397298BActive Publication Date: 2024-09-06HEBEI BAISHA TOBACCO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410854329.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-09-06
Estimated Expiration
2044-06-28

AI Technical Summary

Technical Problem

Existing spatial pyramid pooling methods have problems with insufficient feature extraction and insufficient receptive field expansion in visual analysis, resulting in limited analysis accuracy.

Method used

The self-attention spatial pyramid pooling method based on hybrid pooling is adopted, combining maximum pooling and average pooling, and using the self-attention model to expand the receptive field and enhance the global receptive field to improve visual analysis performance.

Benefits of technology

It effectively improves the model's ability to obtain global information, improves the overall performance of visual analysis, reduces the amount of calculation, and ensures the comprehensiveness and accuracy of feature extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118397298B
    Figure CN118397298B
Patent Text Reader

Abstract

The invention discloses a self-attention space pyramid pooling method based on hybrid pooling and related components, which are applied to the technical field of visual analysis. In order to solve the problem of insufficient feature extraction of existing space pyramid pooling, it is proposed to divide a feature map group of a to-be-analyzed graphic into a first feature map group and a second feature map group; divide the first feature map group into a first sub-feature map group and a second sub-feature map group through a channel allocation layer; adopt a maximum pooling method and an average pooling method to perform pooling processing on the first sub-feature map group and the second sub-feature map group respectively, then splice the obtained maximum pooling feature map group and the average pooling feature map group, adopt a self-attention model to perform an expansion receptive field processing on the spliced ​​pooling feature map group, and obtain a processed expansion feature map group; splice the expansion feature map group with the second feature map group to obtain a space pyramid pooling result; the global receptive field can be improved, which is beneficial to improving the visual analysis performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of visual analysis technology, and in particular to a self-attention spatial pyramid pooling method, device, electronic device and computer-readable storage medium based on hybrid pooling. Background Art

[0002] Image semantic segmentation is essentially the classification of each pixel in the image. Existing semantic segmentation algorithms are mainly designed based on the architecture of encoding and decoding. In the encoder stage, the image is transformed into a feature map rich in high-level semantic information through a series of convolution and pooling operations; in the decoder stage, the feature map is gradually upsampled to produce a prediction result of the same size as the input image. Since this encoding and decoding method requires frequent downsampling and upsampling, a large amount of key information will be lost. There are currently two mainstream solutions to this problem:

[0003] One is to reduce the number of downsampling of the feature extraction model, such as ENet (a speech segmentation algorithm). ENet discards the downsampling in the final stage of the model to pursue an extremely compact framework and reduce the occurrence of key pixel loss caused by downsampling.

[0004] Another method is to use multi-scale fusion. Since the underlying features enable the model to see many texture details of the image, it may be very accurate for a small block of the image, but the model cannot see the entire object. Although the high-level information enables the model to see the entire object, the number of downsampling is too many, and information such as edge details becomes blurred. Therefore, it is very important to combine the feature information of each scale to solve the above problems. For example, the Feature Pyramid Network (FPN) algorithm constructs a top-down hierarchical structure with lateral connections to construct a semantic feature fusion method of each scale. Spatial Pyramid Pooling (SPP) proposes a very effective multi-resolution strategy. After the output of the last convolutional layer, an SPP layer is added. This layer divides the feature map into different scales and performs a pooling operation on each block. In this way, a fixed-size output can be obtained, which is then input into the fully connected layer for tasks such as classification or regression.

[0005] In deep networks, the size of the receptive field roughly reflects the contextual information that the deep learning model can obtain. For the multi-scale fusion method, the spatial pyramid pooling (SPP) has the problem of insufficient feature extraction. SPP only uses a single maximum pooling method to extract features, resulting in insufficient feature extraction. In addition, the SPP method only uses convolution calculations to perform further local feature extraction operations, without maximizing the expansion of the receptive field, which limits the accuracy of visual analysis based on the existing spatial pyramid pooling method.

[0006] In view of this, how to provide a spatial pyramid pooling method, device, electronic device and computer-readable storage medium that can expand the receptive field has become a problem that those skilled in the art need to solve. Summary of the invention

[0007] The purpose of the embodiments of the present invention is to provide a self-attention spatial pyramid pooling method, device, electronic device and computer-readable storage medium based on hybrid pooling, which can improve the global receptive field and reduce the amount of calculation during use, thereby improving the visual analysis performance.

[0008] To solve the above technical problems, the embodiments of the present invention provide the following technical solutions:

[0009] On the one hand, the present invention provides a self-attention spatial pyramid pooling method based on hybrid pooling, comprising:

[0010] Acquire a feature graph group for the graph to be analyzed, and divide the feature graph group into a first feature graph group and a second feature graph group;

[0011] Dividing the first feature map group into a first sub-feature map group and a second sub-feature map group through a channel allocation layer;

[0012] Performing maximum pooling processing on the first sub-feature map group using a maximum pooling method to obtain a maximum pooling feature map group carrying maximum value features;

[0013] Performing average pooling processing on the second sub-feature map group using an average pooling method to obtain an average pooling feature map group carrying average features;

[0014] The maximum pooling feature map group and the average pooling feature map group are spliced, and the self-attention model is used to expand the receptive field of the spliced ​​pooling feature map group to obtain a processed expanded feature map group;

[0015] The expanded feature map group is concatenated with the second feature map group to obtain a spatial pyramid pooling result, so as to perform visual analysis based on the spatial pyramid pooling result.

[0016] In an exemplary embodiment, the self-attention model is used to expand the receptive field of the spliced ​​pooled feature map group to obtain the processed expanded feature map group, including:

[0017] Each pooling feature map in the spliced ​​pooling feature map group is divided into multiple groups of sub-pooling feature map groups according to the preset pooling window size;

[0018] For each group of the sub-pooled feature map groups, a corresponding self-attention unit is used to expand the receptive field of the sub-pooled feature map group to obtain an expanded feature map corresponding to each sub-pooled feature map in the sub-pooled feature map group.

[0019] In an exemplary embodiment, the corresponding self-attention unit is used to expand the receptive field of the sub-pooled feature map group to obtain an expanded feature map corresponding to each sub-pooled feature map in the sub-pooled feature map group, including:

[0020] Processing the sub-pooled feature map group using the first fully connected layer in the self-attention unit to obtain a query feature matrix;

[0021] Processing the sub-pooled feature map group using a second fully connected layer in the self-attention unit to obtain a key feature matrix;

[0022] Using the third fully connected layer in the self-attention unit to process the sub-pooled feature map group to obtain a value feature matrix;

[0023] Using a self-attention calculation relationship to perform calculation based on the query feature matrix, the key feature matrix, and the value feature matrix to obtain a self-attention calculation result;

[0024] Based on the self-attention calculation result, an expanded feature map corresponding to each sub-pooling feature map in the sub-pooling feature map group is obtained.

[0025] In an exemplary embodiment, the self-attention calculation relationship is:

[0026] ,in, represents the result of self-attention calculation, represents the query feature matrix, represents the key feature matrix, represents the value feature matrix, is the weight calculation function, represents the output dimension of the fully connected layer, and T represents the matrix transpose operation.

[0027] In an exemplary embodiment, the step of dividing each pooling feature map in the spliced ​​pooling feature map group into a plurality of sub-pooling feature map groups according to a preset pooling window size includes:

[0028] The pooled feature maps in the spliced ​​pooled feature map group are divided into a 1*1 feature map group, a (2*N+1)*(2*N+1) feature map group, and a (2*N+2)*(2*N+2) feature map group according to the preset pooling window size, where N is an integer not less than 1.

[0029] In an exemplary embodiment, dividing the first feature map group into a first sub-feature map group and a second sub-feature map group by a channel allocation layer includes:

[0030] The first feature map group is divided into a first sub-feature map group and a second sub-feature map group according to a current allocation ratio through a channel allocation layer; wherein the current allocation ratio is obtained after being updated based on the current loss during the visual analysis process.

[0031] In an exemplary implementation, the step of concatenating the expanded feature map group with the second feature map group to obtain a spatial pyramid pooling result includes:

[0032] Randomly shuffling the order of each extended feature map of the extended feature map group;

[0033] Perform channel splicing on each of the shuffled expanded feature maps and then splicing them with the second feature map group to obtain a spliced ​​overall feature map group;

[0034] Information interaction processing is performed on each feature map in the spliced ​​overall feature map group, and each feature map after the information interaction processing is used as a spatial pyramid pooling result.

[0035] Another aspect of the present invention provides a self-attention spatial pyramid pooling device based on hybrid pooling, comprising:

[0036] An acquisition module, used for acquiring a feature graph group for the graph to be analyzed, and dividing the feature graph group into a first feature graph group and a second feature graph group;

[0037] an allocation module, configured to divide the first feature map group into a first sub-feature map group and a second sub-feature map group through a channel allocation layer;

[0038] A maximum pooling module, configured to perform maximum pooling processing on the first sub-feature map group using a maximum pooling method to obtain a maximum pooling feature map group carrying a maximum value feature;

[0039] An average pooling module, used for performing average pooling processing on the second sub-feature map group by using an average pooling method to obtain an average pooling feature map group carrying average features;

[0040] A self-attention module is used to splice the maximum pooling feature map group with the average pooling feature map group, and use a self-attention model to expand the receptive field of the spliced ​​pooling feature map group to obtain a processed expanded feature map group;

[0041] A splicing module is used to splice the expanded feature map group with the second feature map group to obtain a spatial pyramid pooling result, so as to perform visual analysis based on the spatial pyramid pooling result.

[0042] Another aspect of the present invention provides an electronic device, comprising:

[0043] Memory for storing computer programs;

[0044] A processor is used to implement the steps of the self-attention spatial pyramid pooling method based on hybrid pooling as described above when executing the computer program.

[0045] On the other hand, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the self-attention spatial pyramid pooling method based on hybrid pooling as described above are implemented.

[0046] It can be seen from the above technical solutions that the embodiments of the present invention have the following advantages:

[0047] In an embodiment of the present invention, a self-attention spatial pyramid pooling method based on hybrid pooling is provided, comprising: obtaining a feature map group for a to-be-analyzed graphic, and dividing the feature map group into a first feature map group and a second feature map group; dividing the first feature map group into a first sub-feature map group and a second sub-feature map group through a channel allocation layer; performing maximum pooling processing on the first sub-feature map group by a maximum pooling method to obtain a maximum pooling feature map group carrying a maximum value feature; performing average pooling processing on the second sub-feature map group by an average pooling method to obtain an average pooling feature map group carrying an average feature; splicing the maximum pooling feature map group and the average pooling feature map group, and performing an expanded receptive field processing on the spliced ​​pooling feature map group by a self-attention model to obtain a processed expanded feature map group; splicing the expanded feature map group with the second feature map group to obtain a spatial pyramid pooling result, so as to perform visual analysis based on the spatial pyramid pooling result.

[0048] It can be seen that in the embodiment of the present invention, the feature map group of the graphics to be analyzed is divided into two groups, and the first feature map group is further divided into a first sub-feature map group and a second sub-feature map group through a channel allocation layer, and the maximum pooling method and the average pooling method are respectively used to perform pooling processing on the first sub-feature map group and the second sub-feature map group, and then the obtained maximum pooling feature map group is spliced ​​with the average pooling feature map group, and then the self-attention model is further used to expand the receptive field of the spliced ​​pooling feature map group to obtain the processed expanded feature map group, and then the expanded feature map group is spliced ​​with the second feature map group to obtain the spatial pyramid pooling result. Since the feature map is first divided by the channel allocation layer in the present application, the amount of calculation can be reduced, and the maximum pooling method and the average pooling method are combined for feature extraction, which can make the extracted features more comprehensive, and then the self-attention model is used to expand the receptive field, which can improve the global receptive field, effectively improve the model's ability to obtain global information, and is conducive to improving the overall performance of visual analysis.

[0049] In addition, the present invention also provides a corresponding implementation device, electronic device and computer-readable storage medium for the self-attention spatial pyramid pooling method based on hybrid pooling, which further makes the method more practical, and the device, electronic device and computer-readable storage medium have corresponding advantages.

[0050] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the prior art and the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0052] Figure 1 A schematic diagram of a process of a self-attention spatial pyramid pooling method based on hybrid pooling provided in an embodiment of the present invention;

[0053] Figure 2 An overall structure diagram of a visual task provided by an embodiment of the present invention;

[0054] Figure 3 A schematic diagram of a self-attention spatial pyramid pooling architecture based on hybrid pooling provided in an embodiment of the present invention;

[0055] Figure 4 A schematic diagram of the structure of a self-attention layer provided by an embodiment of the present invention;

[0056] Figure 5 A schematic diagram of the structure of a self-attention spatial pyramid pooling device based on hybrid pooling provided by an embodiment of the present invention;

[0057] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;

[0058] Figure 7 A schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0059] The embodiments of the present invention provide a self-attention spatial pyramid pooling method, device, electronic device and computer-readable storage medium based on hybrid pooling, which can improve the global receptive field, reduce the amount of calculation during use, and help improve visual analysis performance.

[0060] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0061] Please refer to Figure 1 , Figure 1 A schematic diagram of a flow chart of a self-attention spatial pyramid pooling method based on hybrid pooling provided by an embodiment of the present invention. The spatial pyramid pooling method comprises:

[0062] S110: Acquire a feature graph group for the graph to be analyzed, and divide the feature graph group into a first feature graph group and a second feature graph group;

[0063] It should be noted that if Figure 2As shown in the overall structure diagram of the visual task, the spatial pyramid pooling method is only a component of the entire visual task (such as target detection, semantic segmentation), which is mainly connected behind the feature extraction network (such as ResNet, DenseNet and VGGNet, etc.). The method provided in the embodiment of the present invention is applied to the spatial pyramid pooling module, and the spatial pyramid pooling method in the spatial pyramid pooling module is optimized. In practical applications, after the graphics to be analyzed are input, a feature map group is obtained after extraction by the feature extraction network. The feature map group includes multiple feature maps. In the embodiment of the present invention, the feature map group is used as input. After obtaining the feature map group, the feature map group is divided into two parts (specifically, it can be evenly divided into two parts), one part Part_1 (that is, the first feature map group) is input to the channel allocation layer for channel allocation, and the other part Part_2 (that is, the second feature map group) is directly input to the channel splicing of the post-calculation processing, such as Figure 3 It is understandable that in the embodiment of the present invention, the feature map group is divided into a first feature map group and a second feature map group, which can reduce the amount of calculation while ensuring the effect of pyramid pooling, thereby balancing the feature extraction effect and the calculation efficiency.

[0064] S120: dividing the first feature map group into a first sub-feature map group and a second sub-feature map group through a channel allocation layer;

[0065] It should be noted that in order to use average pooling and maximum pooling with maximum efficiency in the embodiment of the present invention, and to prevent the model from being overly biased towards one of the pooling methods while significantly reducing the amount of calculation, resulting in waste of resources, a channel allocation layer is added before the maximum pooling layer and the average pooling layer. The channel allocation layer has learnable parameters for allocating input channels for average pooling and maximum pooling.

[0066] Specifically, after the first feature map group in the embodiment of the present invention enters the channel allocation layer, the channel allocation layer can divide the first feature map group into a first sub-feature map group and a second sub-feature map group based on current parameters (such as a current allocation ratio).

[0067] Among them, the current parameter (such as the current allocation ratio) is obtained by updating the previous allocation ratio based on the current loss during the entire visual analysis process.

[0068] S130: performing maximum pooling processing on the first sub-feature map group using a maximum pooling method to obtain a maximum pooling feature map group carrying maximum value features;

[0069] It can be understood that in the embodiment of the present invention, the maximum pooling method is used to perform maximum pooling processing on each first sub-feature map in the first sub-feature map group to obtain the first sub-feature map after maximum pooling carrying the maximum value feature, thereby obtaining the maximum pooling feature map group, that is, the maximum pooling feature group includes the first sub-feature map after maximum pooling corresponding to each first sub-feature map. Since the maximum pooling method can retain the most significant feature information by selecting the maximum value in the local area as the output, the maximum pooling method is used to perform maximum pooling processing on the first sub-feature map group, which helps to better capture the key features.

[0070] S140: performing average pooling processing on the second sub-feature map group using an average pooling method to obtain an average pooling feature map group carrying average features;

[0071] It can be understood that in the embodiment of the present invention, the average pooling method is used to perform average pooling processing on each second sub-feature map in the second sub-feature map group to obtain the second sub-feature map after average pooling carrying the average feature, thereby obtaining the average pooling feature map group, which includes the second sub-feature map after average pooling corresponding to each second sub-feature map. Since average pooling averages all feature values ​​in the local area, that is, average pooling takes into account all features of the local area, average pooling has strong robustness to small changes or noise in the input data, which helps the model better cope with various scenarios.

[0072] S150: splicing the maximum pooling feature map group and the average pooling feature map group, and using the self-attention model to expand the receptive field of the spliced ​​pooling feature map group to obtain a processed expanded feature map group;

[0073] It should be noted that in order to better preserve detail features in the embodiment of the present invention, the maximum pooling feature map group and the average pooling feature map group can be fused by channel splicing. Compared with the conventional point-by-point addition and fusion method, the channel splicing method can better preserve detail features.

[0074] Specifically, after channel splicing, the self-attention model can be further used to expand the receptive field of the spliced ​​pooled feature map group to obtain the processed expanded feature map group, wherein the self-attention mechanism can enhance the global receptive field and effectively increase the model's ability to obtain global information.

[0075] Exemplarily, the process of using the self-attention model to expand the receptive field of the spliced ​​pooled feature map group in S150 to obtain the processed expanded feature map group may include:

[0076] Each pooling feature map in the spliced ​​pooling feature map group is divided into multiple groups of sub-pooling feature map groups according to the preset pooling window size;

[0077] For each group of sub-pooled feature maps, the corresponding self-attention unit is used to expand the receptive field of the sub-pooled feature map group to obtain an expanded feature map corresponding to each sub-pooled feature map in the sub-pooled feature map group.

[0078] It should be noted that if Figure 3 As shown, in the embodiment of the present invention, three different pooling windows can be used, so that the size of the feature map group after pooling is 1*1, (2*N+1) *(2*N+1) and (2*N+2)*(2*N+2). Therefore, each pooling feature map in the spliced ​​pooling feature map group can be divided into multiple groups of sub-pooling feature map groups according to the preset pooling window size. That is, the feature map size of 1*1 is divided into a group to obtain a 1*1 feature map group; the feature map size of (2*N+1)*(2*N+1) is divided into a group to obtain a (2*N+1)*(2*N+1) feature map group; the feature map size of (2*N+2)*(2*N+2) is divided into a group to obtain a (2*N+2)*(2*N+2) feature map group. Among them, N takes integers such as 1, 2..., and the specific value of N can be determined according to the actual situation, but the value of N should not be too large, which is easy to increase the amount of calculation.

[0079] Specifically, the self-attention model includes self-attention units corresponding to each preset pooling window size. After determining each group of sub-pooling feature maps, the corresponding self-attention unit can be used to expand the receptive field of each sub-pooling feature map in the sub-pooling feature map group to obtain the corresponding expanded feature map. The expanded feature map contains full-image feature information, thereby improving the global receptive field and helping to increase the model's ability to obtain global information.

[0080] Furthermore, the process of using the corresponding self-attention unit to expand the receptive field of the sub-pooled feature map group to obtain an expanded feature map corresponding to each sub-pooled feature map in the sub-pooled feature map group may include:

[0081] The first fully connected layer in the self-attention unit is used to process the sub-pooled feature map group to obtain the query feature matrix;

[0082] The second fully connected layer in the self-attention unit is used to process the sub-pooled feature map group to obtain the key feature matrix;

[0083] The third fully connected layer in the self-attention unit is used to process the sub-pooled feature map group to obtain the value feature matrix;

[0084] The self-attention calculation formula is used to calculate based on the query feature matrix, the key feature matrix and the value feature matrix to obtain the self-attention calculation result;

[0085] Based on the self-attention calculation result, an expanded feature map corresponding to each sub-pooled feature map in the sub-pooled feature map group is obtained.

[0086] It should be noted that each self-attention unit in the embodiment of the present invention includes three fully connected layers, such as Figure 4 As shown, the embodiment of the present invention takes a self-attention unit as an example for detailed description. For the input sub-pooled feature map group, the sub-pooled feature map group is processed by the first fully connected layer 1 to obtain the query feature matrix Q, the sub-pooled feature map group is processed by the second fully connected layer 2 to obtain the key feature matrix K, and the sub-pooled feature map group is processed by the third fully connected layer 3 to obtain the value feature matrix V. Then, the self-attention calculation relationship is further used to calculate based on the query feature matrix, the key feature matrix and the value feature matrix to obtain the self-attention calculation result. Among them, the self-attention calculation relationship is:

[0087] ,in, represents the result of self-attention calculation, represents the query feature matrix, represents the key feature matrix, represents the value feature matrix, is the weight calculation function, represents the output dimension of the fully connected layer, and T represents the matrix transpose operation.

[0088] In the embodiment of the present invention, after obtaining the self-attention calculation result corresponding to the sub-pooling feature map group, an expanded feature map corresponding to each sub-pooling feature map in the sub-pooling feature map group can be further obtained.

[0089] It can be understood that the use of the self-attention mechanism in the embodiment of the present invention can improve the effect of global feature extraction and further expand the receptive field of the model.

[0090] S160: Concatenate the expanded feature map group and the second feature map group to obtain a spatial pyramid pooling result, so as to perform visual analysis based on the spatial pyramid pooling result.

[0091] It should be noted that, in the embodiment of the present invention, after obtaining each extended feature map, an extended feature map group can be formed. In order to prevent the model from being biased towards a certain feature map group and reducing resource utilization during the training process, the extended feature map group can be channel-joined with the second feature map group obtained in S110 to fuse feature information, and the feature map group after information fusion is used as the spatial pyramid pooling result, so that visual analysis can be performed based on the spatial pyramid pooling result to obtain a visual analysis result, and the current loss is further obtained based on the visual analysis result. When the current loss does not meet the preset requirements, the parameters in the entire model (such as the channel allocation ratio of the channel allocation layer, the parameters of each fully connected layer in the self-attention model, etc.) are updated according to the current loss to enter the next round of training, etc.

[0092] Furthermore, the process of concatenating the expanded feature map group with the second feature map group in S160 to obtain a spatial pyramid pooling result may include:

[0093] Randomly shuffle the order of each extended feature map in the extended feature map group;

[0094] The shuffled expanded feature maps are channel-joined and then joined with the second feature map group to obtain a joined overall feature map group;

[0095] Information interaction processing is performed on each feature map in the spliced ​​overall feature map group, and each feature map after the information interaction processing is used as the spatial pyramid pooling result.

[0096] It should be noted that if Figure 3 As shown, in the embodiment of the present invention, after obtaining the expanded feature map group, the order of each expanded feature map in the expanded feature map group can be randomly shuffled, and then the randomly shuffled expanded feature maps are channel-spliced ​​and then channel-spliced ​​with the second feature map group to obtain the spliced ​​overall feature map group. In order to further enhance the correlation of feature information, information interaction processing can be performed on each feature map in the spliced ​​overall feature map group. Specifically, 1*1 convolution can be used to perform information interaction between each feature map, and each feature map after information interaction processing is used as a spatial pyramid pooling result, which is beneficial to improving the performance of visual tasks such as semantic segmentation.

[0097] It can be seen that in the embodiment of the present invention, the feature map group of the graphics to be analyzed is divided into two groups, and the first feature map group is further divided into a first sub-feature map group and a second sub-feature map group through a channel allocation layer, and the maximum pooling method and the average pooling method are respectively used to perform pooling processing on the first sub-feature map group and the second sub-feature map group, and then the obtained maximum pooling feature map group is spliced ​​with the average pooling feature map group, and then the self-attention model is further used to expand the receptive field of the spliced ​​pooling feature map group to obtain the processed expanded feature map group, and then the expanded feature map group is spliced ​​with the second feature map group to obtain the spatial pyramid pooling result. Since the feature map is first divided by the channel allocation layer in the present application, the amount of calculation can be reduced, and the maximum pooling method and the average pooling method are combined for feature extraction, which can make the extracted features more comprehensive, and then the self-attention model is used to expand the receptive field, which can improve the global receptive field, effectively improve the model's ability to obtain global information, and is conducive to improving the overall performance of visual analysis.

[0098] The present invention also provides a corresponding device for the spatial pyramid pooling method, which further makes the method more practical. Among them, the device can be described from the perspective of functional modules and hardware. The spatial pyramid pooling device provided by the present invention is introduced below. The device is used to implement the spatial pyramid pooling method provided by the present invention. In this embodiment, the spatial pyramid pooling device may include or be divided into one or more program modules, which are stored in a storage medium and executed by one or more processors to complete the spatial pyramid pooling method disclosed in the above embodiment. The program module referred to in the present invention refers to a series of computer program instruction segments that can complete specific functions, which is more suitable for describing the execution process of the spatial pyramid pooling device in the storage medium than the program itself. The following description will specifically introduce the functions of each program module of this embodiment, and the spatial pyramid pooling device described below and the spatial pyramid pooling method described above can be referred to each other.

[0099] From the perspective of functional modules, see Figure 5 , Figure 5 A structural diagram of a spatial pyramid pooling device provided by the present invention in a specific implementation manner, the device may include:

[0100] An acquisition module 11 is used to acquire a feature graph group for the graph to be analyzed, and divide the feature graph group into a first feature graph group and a second feature graph group;

[0101] An allocation module 12, configured to divide the first feature map group into a first sub-feature map group and a second sub-feature map group through a channel allocation layer;

[0102] The maximum pooling module 13 is used to perform maximum pooling processing on the first sub-feature map group using the maximum pooling method to obtain a maximum pooling feature map group carrying a maximum value feature;

[0103] An average pooling module 14 is used to perform average pooling processing on the second sub-feature map group using an average pooling method to obtain an average pooling feature map group carrying average features;

[0104] A self-attention module 15 is used to concatenate the maximum pooling feature map group with the average pooling feature map group, and use a self-attention model to expand the receptive field of the concatenated pooling feature map group to obtain a processed expanded feature map group;

[0105] The splicing module 16 is used to splice the expanded feature map group with the second feature map group to obtain a spatial pyramid pooling result, so as to perform visual analysis based on the spatial pyramid pooling result.

[0106] In an exemplary embodiment, the self-attention module 15 includes:

[0107] A first grouping unit is used to divide each pooling feature map in the spliced ​​pooling feature map group into a plurality of sub-pooling feature map groups according to a preset pooling window size;

[0108] The expansion unit is used to expand the receptive field of each group of sub-pooled feature maps by using the corresponding self-attention unit to obtain an expanded feature map corresponding to each sub-pooled feature map in the sub-pooled feature map group.

[0109] In an exemplary embodiment, the expansion unit includes:

[0110] A first processing subunit is used to process the sub-pooled feature map group using the first fully connected layer in the self-attention unit to obtain a query feature matrix;

[0111] A second processing subunit is used to process the sub-pooled feature map group using the second fully connected layer in the self-attention unit to obtain a key feature matrix;

[0112] A third processing subunit is used to process the sub-pooled feature map group using the third fully connected layer in the self-attention unit to obtain a value feature matrix;

[0113] A calculation subunit, used to calculate based on the query feature matrix, the key feature matrix and the value feature matrix using a self-attention calculation relation to obtain a self-attention calculation result;

[0114] Determine a subunit for obtaining an expanded feature map corresponding to each sub-pooled feature map in the sub-pooled feature map group based on the self-attention calculation result.

[0115] In an exemplary embodiment, the self-attention calculation relationship is:

[0116] ,in, represents the result of self-attention calculation, represents the query feature matrix, represents the key feature matrix, represents the value feature matrix, is the weight calculation function, represents the output dimension of the fully connected layer, and T represents the matrix transpose operation.

[0117] In an exemplary embodiment, the first grouping unit is used to:

[0118] The pooled feature maps in the spliced ​​pooled feature map group are divided into a 1*1 feature map group, a (2*N+1)*(2*N+1) feature map group, and a (2*N+2)*(2*N+2) feature map group according to the preset pooling window size, where N is an integer not less than 1.

[0119] In an exemplary embodiment, the allocation module 12 is used to:

[0120] The first feature map group is divided into a first sub-feature map group and a second sub-feature map group according to a current allocation ratio through a channel allocation layer; wherein the current allocation ratio is obtained after being updated based on the current loss during the visual analysis process.

[0121] In an exemplary embodiment, the splicing module 16 includes:

[0122] A shuffling unit, used for randomly shuffling the order of each extended feature map of the extended feature map group;

[0123] A splicing unit, used for splicing the shuffled expanded feature maps through channels and then splicing them with the second feature map group to obtain a spliced ​​overall feature map group;

[0124] The processing unit is used to perform information interaction processing on each feature map in the spliced ​​overall feature map group, and use each feature map after the information interaction processing as a spatial pyramid pooling result.

[0125] It should be noted that the spatial pyramid pooling device in the embodiment of the present invention has the same beneficial effects as the spatial pyramid pooling method provided in the above embodiment, and for the specific introduction of the spatial pyramid pooling method involved in the embodiment of the present invention, please refer to the above embodiment, and this application will not repeat it here.

[0126] The spatial pyramid pooling device mentioned above is described from the perspective of functional modules. Furthermore, the present invention also provides an electronic device, which is described from the perspective of hardware. Figure 6 A structural diagram of an electronic device provided in an embodiment of the present application, such as Figure 6 As shown, the electronic device includes: a memory 20 for storing a computer program;

[0127] The processor 21 is configured to implement the steps of the spatial pyramid pooling method in the above embodiment when executing a computer program.

[0128] The electronic device provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer or a desktop computer.

[0129] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0130] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the memory 20 may be an internal storage unit of an electronic device, such as a hard disk of a server. In other embodiments, the memory 20 may also be an external storage device of an electronic device, such as a plug-in hard disk equipped on a server, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. Further, the memory 20 may also include both an internal storage unit of an electronic device and an external storage device. The memory 20 may not only be used to store application software and various types of data installed in the electronic device, such as: the code of the program in the process of executing the spatial pyramid pooling method, etc., but may also be used to temporarily store data that has been output or is to be output. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, the relevant steps of the spatial pyramid pooling method disclosed in any of the aforementioned embodiments can be implemented. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. The operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include but is not limited to (data corresponding to the spatial pyramid pooling result) and the like.

[0131] In some embodiments, the electronic device may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26. Among them, the display screen 22 and the input / output interface 23, such as a keyboard, belong to the user interface, and the optional user interface may also include a standard wired interface, a wireless interface, and the like. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, and the like. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface. The communication interface 24 may optionally include a wired interface and / or a wireless interface, such as a WI-FI interface, a Bluetooth interface, and the like, which are generally used to establish a communication connection between the electronic device and other electronic devices. The communication bus 26 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, and the like. The bus may be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0132] Those skilled in the art will understand that Figure 6 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure.

[0133] It is understandable that if the spatial pyramid pooling method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, disk or optical disk and other media that can store program code.

[0134] Based on this, Figure 7As shown, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program 31 is stored. When the computer program 31 is executed by a processor, the steps of the above-mentioned spatial pyramid pooling method are implemented.

[0135] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0136] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0137] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A self-attention spatial pyramid pooling method based on hybrid pooling, characterized in that: include: Acquire a feature graph group for the graph to be analyzed, and divide the feature graph group into a first feature graph group and a second feature graph group; Dividing the first feature map group into a first sub-feature map group and a second sub-feature map group through a channel allocation layer; Performing maximum pooling processing on the first sub-feature map group using a maximum pooling method to obtain a maximum pooling feature map group carrying maximum value features; Performing average pooling processing on the second sub-feature map group using an average pooling method to obtain an average pooling feature map group carrying average features; The maximum pooling feature map group and the average pooling feature map group are spliced, and the self-attention model is used to expand the receptive field of the spliced ​​pooling feature map group to obtain a processed expanded feature map group; The expanded feature map group and the second feature map group are concatenated to obtain a spatial pyramid pooling result, so as to perform visual analysis based on the spatial pyramid pooling result; wherein: The self-attention model is used to expand the receptive field of the spliced ​​pooled feature map group to obtain the processed expanded feature map group, including: Each pooling feature map in the spliced ​​pooling feature map group is divided into multiple groups of sub-pooling feature map groups according to the preset pooling window size; For each group of the sub-pooled feature map groups, a corresponding self-attention unit is used to expand the receptive field of the sub-pooled feature map group to obtain an expanded feature map corresponding to each sub-pooled feature map in the sub-pooled feature map group; The using the corresponding self-attention unit to perform an expanded receptive field process on the sub-pooled feature map group to obtain an expanded feature map corresponding to each sub-pooled feature map in the sub-pooled feature map group includes: Processing the sub-pooled feature map group using the first fully connected layer in the self-attention unit to obtain a query feature matrix; Processing the sub-pooled feature map group using a second fully connected layer in the self-attention unit to obtain a key feature matrix; Using the third fully connected layer in the self-attention unit to process the sub-pooled feature map group to obtain a value feature matrix; Using a self-attention calculation relationship to perform calculation based on the query feature matrix, the key feature matrix, and the value feature matrix to obtain a self-attention calculation result; Based on the self-attention calculation result, an expanded feature map corresponding to each sub-pooling feature map in the sub-pooling feature map group is obtained.

2. The spatial pyramid pooling method according to claim 1, wherein: The self-attention calculation formula is: ,in, represents the result of self-attention calculation, Q represents the query feature matrix, K represents the key feature matrix, V represents the value feature matrix, Softmax is the weight calculation function, d represents the output dimension of the fully connected layer, T Represents a matrix transpose operation.

3. The spatial pyramid pooling method according to claim 1, wherein: The step of dividing each pooling feature map in the spliced ​​pooling feature map group into a plurality of sub-pooling feature map groups according to a preset pooling window size includes: The pooled feature maps in the spliced ​​pooled feature map group are divided into a 1*1 feature map group, a (2*N+1) *(2*N+1) feature map group and a (2*N+2) *(2*N+2) feature map group according to the preset pooling window size, where N is an integer not less than 1.

4. The spatial pyramid pooling method according to claim 1, wherein: The step of dividing the first feature map group into a first sub-feature map group and a second sub-feature map group by a channel allocation layer comprises: The first feature map group is divided into a first sub-feature map group and a second sub-feature map group according to a current allocation ratio through a channel allocation layer; wherein the current allocation ratio is obtained after being updated based on the current loss during the visual analysis process.

5. The spatial pyramid pooling method according to any one of claims 1 to 4, characterized in that: The step of concatenating the expanded feature map group with the second feature map group to obtain a spatial pyramid pooling result includes: Randomly shuffling the order of each extended feature map of the extended feature map group; Perform channel splicing on each of the shuffled expanded feature maps and then splicing them with the second feature map group to obtain a spliced ​​overall feature map group; Information interaction processing is performed on each feature map in the spliced ​​overall feature map group, and each feature map after the information interaction processing is used as a spatial pyramid pooling result.

6. A self-attention spatial pyramid pooling device based on hybrid pooling, characterized in that: include: An acquisition module, used for acquiring a feature graph group for the graph to be analyzed, and dividing the feature graph group into a first feature graph group and a second feature graph group; an allocation module, configured to divide the first feature map group into a first sub-feature map group and a second sub-feature map group through a channel allocation layer; A maximum pooling module, configured to perform maximum pooling processing on the first sub-feature map group using a maximum pooling method to obtain a maximum pooling feature map group carrying a maximum value feature; An average pooling module, used for performing average pooling processing on the second sub-feature map group by using an average pooling method to obtain an average pooling feature map group carrying average features; A self-attention module is used to splice the maximum pooling feature map group with the average pooling feature map group, and use a self-attention model to expand the receptive field of the spliced ​​pooling feature map group to obtain a processed expanded feature map group; A splicing module is used to splice the expanded feature map group with the second feature map group to obtain a spatial pyramid pooling result, so as to perform visual analysis based on the spatial pyramid pooling result; wherein: The self-attention module comprises: A first grouping unit is used to divide each pooling feature map in the spliced ​​pooling feature map group into a plurality of sub-pooling feature map groups according to a preset pooling window size; An expansion unit, for each group of the sub-pooled feature map groups, using a corresponding self-attention unit to perform an expansion receptive field process on the sub-pooled feature map group to obtain an expanded feature map corresponding to each sub-pooled feature map in the sub-pooled feature map group; The expansion unit comprises: A first processing subunit is used to process the sub-pooled feature map group using the first fully connected layer in the self-attention unit to obtain a query feature matrix; A second processing subunit is used to process the sub-pooled feature map group using the second fully connected layer in the self-attention unit to obtain a key feature matrix; A third processing subunit is used to process the sub-pooled feature map group using the third fully connected layer in the self-attention unit to obtain a value feature matrix; A calculation subunit, used to calculate based on the query feature matrix, the key feature matrix and the value feature matrix using a self-attention calculation relation to obtain a self-attention calculation result; Determine a subunit, which is used to obtain an expanded feature map corresponding to each sub-pooling feature map in the sub-pooling feature map group based on the self-attention calculation result.

7. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the spatial pyramid pooling method according to any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the spatial pyramid pooling method according to any one of claims 1 to 5 are implemented.