A global self-attention object detection method combined with channel spatial attention
By combining the global self-attention target detection method with channel spatial attention, and combining the channel and spatial attention mechanisms, the problem of insufficient high-level feature extraction capabilities and loss of detailed information of the deep learning model is solved, and the accuracy of target detection is improved.
Patent Information
- Application Number
- CN202210045872.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-17
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-01-17
AI Technical Summary
Existing target detection models have problems with poor robustness and high computational complexity in the feature extraction process, especially the deep learning model's insufficient high-level feature extraction capabilities and the detailed information caused by the channel spatial attention mechanism's dimensionality reduction through the fully connected layer. loss.
A global self-attention target detection method that combines channel spatial attention is designed. Features are extracted through the three branches of Key, Query, and Value. The channel and spatial attention mechanisms are combined, and one-dimensional convolution and convolution layers are used for information interaction. and dimensionality reduction, generating a covariance matrix to enhance the global relevant information of the feature image and avoid information loss through the residual structure.
It improves the accuracy of target detection and feature extraction capabilities, solves the problem of loss of detailed information, and achieves better results in target detection tasks, with detection accuracy increased by 1.2%.
Smart Images

Figure CN114519807B
Abstract
Description
Technical Field
[0001] The present invention relates to a global self-attention target detection algorithm combined with channel spatial attention, which is applicable to the field of computer vision. Background Art
[0002] Object detection is an important problem in computer vision. Traditional object detection models use manually extracted features, which have problems such as poor robustness and high computational complexity, and are difficult to meet the requirements of real-time and accuracy of object detection. With the great progress made by deep learning in image classification tasks, object detection algorithms based on deep learning have gradually become mainstream. The application of convolutional neural networks has greatly improved the prediction accuracy and training speed of object detection.
[0003] At present, there are two main types of target detection technologies based on deep learning: two-stage and one-stage. Two-stage means that the detection algorithm needs to be completed in two steps. First, a convolutional neural network is used to extract features of the target to obtain candidate regions, and then detection and classification are performed. Common algorithms include Faster-RCNN [1] ; One-stage means that the detection algorithm has only one step, and there is no need to find candidate areas. Only one convolutional neural network is used to detect the target. This method has a fast detection speed, but the accuracy is low. As the number of layers of the convolutional neural network increases, the network representation ability becomes stronger, but the loss of the target's location information is also increasing. In recent years, the method of enhancing the network's representation ability and reducing the loss of target information through the attention mechanism has been widely used in image classification and detection tasks. The attention model has also become one of the core technologies in deep learning technology that deserves the most attention and in-depth understanding.
[0004] The attention model is based on the attention mechanism of human vision. Human vision quickly scans the global image to obtain the target area that needs to be focused on, which is generally referred to as the focus of attention. Then, more attention resources are invested in this area to obtain more detailed information about the target that needs to be focused on, while suppressing other useless information. This is a means for humans to use limited attention resources to quickly filter out high-value information from a large amount of information. It is a survival mechanism formed by humans in long-term evolution. The human visual attention mechanism greatly improves the efficiency and accuracy of visual information processing.
[0005] The attention mechanism in deep learning is essentially similar to the selective visual attention mechanism of humans. The core goal is to select the more critical information for the current task from a large amount of information. [2]It is a channel attention mechanism that first performs global average pooling on the input features to obtain the global information of each channel, and then obtains the weight of each channel through two fully connected layers and a sigmoid function. [3] It is a channel-space attention mechanism. The spatial attention module is added after the channel attention module, so that both spatial and channel attention can be combined to better extract features. However, both channel and spatial attention are implemented through convolution, which only considers the local area, ignores the global information, and ignores the connection between the predicted pixel and other pixels.
[0006] References:
[0007] [1]Ren S,He K,Girshick R,et al.Faster R-CNN:Towards Real-Time ObjectDetection with Region Proposal Networks[J].IEEE Transactions on PatternAnalysis&Machine Intelligence,2017,39(6):1137-1149.
[0008] [2]Hu J, Shen L, Sun G. Squeeze-and-excitation networks[C]. Proceedings of the IEEE conference on computer vision and pattern recognition. 2018:7132-7141.
[0009] [3]Woo S,Park J,Lee JY,et al.Cbam:Convolutional block attentionmodule[C].Proceedings of the European conference on computer vision(ECCV).2018:3-19
[0010] [4] Zhu Z, Liang D, Zhang S, et al. Traffic-sign detection and classification in the wild [C]. Proceedings of the IEEE Conference on ComputerVision and Pattern Recognition. 2016: 2110-2118.
[0011] [5]Yu F,Wang D,Shelhamer E,et al.Deep Layer Aggregation[C]Proceedings of the IEEE conference on computer vision and pattern recognition.2018:2403-2412 Summary of the invention
[0012] Aiming at the problem that the high-level feature extraction capability of the target detection network DLA34 is insufficient, and the existing channel space attention mechanism has the problem that the dimension reduction method of the fully connected layer is used to cause the loss of some detail information, which has a certain negative impact on the performance of the detection task, the present invention proposes a global self-attention target detection method combined with channel space attention. The technical solution is as follows:
[0013] A global self-attention target detection method combined with channel spatial attention comprises the following steps:
[0014] The first step is to extract the feature image F;
[0015] In the second step, a global self-attention module with joint channel spatial attention is designed, and the three branches of Key, Query, and Value are used to further extract features. The feature image F input into the global self-attention module with joint channel spatial attention is assumed to be C×W×H, where C is the number of channels in the feature map, and W and H represent the size of the feature map. The global self-attention module with joint channel spatial attention is divided into three branches, where:
[0016] (1) The Key branch is a channel attention mechanism, which takes the global average pooling of the feature image F to transform it into a tensor of size C×1×1, uses a one-dimensional convolution operation on the tensor to perform local channel information interaction, and uses sigmoid to convert the interaction result into a channel weight, thereby obtaining a channel attention weight vector Key of size C×1;
[0017] (2) The query branch is a spatial attention mechanism, which performs global maximum pooling and global average pooling on the feature image F to obtain two H×W×1 feature maps. The two H×W×1 feature maps are then concatenated and dimensionality reduced using a convolutional layer. The sigmoid layer is used to convert the reduced dimensionality result into a spatial weight. Finally, the spatial weight is multiplied by the feature image F to obtain the spatial attention feature.
[0018] (3) The Value branch is the feature image F;
[0019] (4) After performing matrix multiplication operation on the Key branch and the Query branch, the covariance matrix is normalized using softmax to obtain the covariance matrix, and the obtained covariance matrix is matrix multiplied with the Value branch to obtain the enhanced feature image F', so as to enhance the input feature image with global relevant information. At the same time, the feature image F and the enhanced feature image F' are added as the residual structure to avoid network degradation, thereby obtaining the final generated channel space self-attention feature.
[0020] In the third step, the data set is used to train the network with the global self-attention module with joint channel spatial attention. The predicted candidate box is obtained through forward propagation. The L2 norm is used as the loss function to calculate the error between the predicted candidate box and the target candidate box and perform back propagation. The ADAM optimizer is used to continuously optimize until the error no longer decreases, thereby obtaining a trained network parameter model.
[0021] Furthermore, the feature image F is extracted through the backbone network deep fusion feature network DLA.
[0022] The beneficial effects of the present invention are as follows:
[0023] 1. The channel attention and spatial attention mechanisms in the module respectively enhance the channel information and spatial information of the feature image. In addition, the use of weight-sharing one-dimensional convolution in the channel attention effectively solves the problem of detail information loss caused by direct downsampling and obtains the channel weights of the corresponding feature image.
[0024] 2. Integrate channel and spatial attention into the self-attention mechanism. In the deep part of the backbone network, the principle of the self-attention mechanism based on the covariance matrix is used to couple the correlation information between the global pixels of the image. The covariance matrix is obtained by using channel attention and spatial attention, and then the covariance matrix is multiplied with the input image feature points to achieve global feature enhancement of the original input image features.
[0025] 3. The proposed global self-attention module with joint channel spatial attention has consistent input and output channel dimensions and can be arbitrarily assembled into convolutional neural networks, with high generalization and scalability. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 This is a structural diagram of the global self-attention module with joint channel spatial attention designed by the present invention. DETAILED DESCRIPTION
[0027] The present invention proposes a global self-attention target detection algorithm combined with channel-spatial attention, which uses an improved channel-spatial joint attention network to obtain enhanced features of coupled channel and spatial information; and constructs a global self-attention network, which effectively captures the global correlation between pixels with the help of the covariance information between the enhanced features and the original features, overcomes the problem that traditional convolution is limited to adjacent pixels, and achieves better results in target detection tasks.
[0028] The following will further describe the implementation scheme in detail with reference to the network in the accompanying drawings:
[0029] (1) Data preparation:
[0030] Divide the data set. This method uses the traffic sign data set TT100K [4] , This dataset is jointly produced by Tsinghua University and Tencent. It is collected from 5 cities in China, including 10 blocks. It includes different weather, different lighting and partial occlusion in real driving scenes. The dataset contains a total of 182 types of traffic signs. The resolution of each image is 2048×2048, a total of 9176 images. In the experiment, the categories with less than 100 instances are ignored, and the 45 types of traffic signs with more than 100 instances in the dataset are used. Since traffic signs account for a small proportion of high-resolution images, in order to facilitate training, the original high-resolution images are manually cropped into sub-images with a resolution of 512×512 pixels in the experiment. According to the commonly used dataset segmentation method, we split the dataset into a training set and a test set.
[0031] (2) Network construction: The network structure of the present invention mainly adds a channel space self-attention module to the deep network layer of the backbone network to improve the feature extraction ability of the network in the channel space, thereby improving the accuracy of target detection. Figure 1 , and a detailed introduction and description of the network structure constructed by the invention is given.
[0032] (a) In each iteration, the input training set image is passed through the backbone network deep fusion feature network DLA (Deep Layer Aggregation) [5]To extract the feature image F, the backbone network consists of six parts. The first two parts are convolutional layer structures, which consist of a two-dimensional convolutional layer, a batch normalization layer, and an activation function layer to preliminarily extract shallow image features. The last four parts are a convolutional structure HDA (Hierarchical Deep Aggregation) that deeply integrates features. [5] , using IDA (Iterative Deep Aggregation) [5] To connect the features between two adjacent layers;
[0033] (b) The feature image F obtained in the previous step is input into the global self-attention module of the joint channel spatial attention. The specific algorithm of the global self-attention module of the joint channel spatial attention is as follows:
[0034] In order to establish the connection between pixels with a certain distance on the image, it is necessary to consider the weighting of all position features, namely space, channel, etc. The feature image F is processed differently to obtain the output of the three branches of Key, Query, and Value. The size of the feature image F is C×W×H, where C is the number of channels of the feature map, and W and H represent the size of the feature map.
[0035] The Key branch is the channel attention mechanism, which takes the global average pooling of the feature image F to make it a tensor of size C×1×1, uses a one-dimensional convolution operation on the tensor to perform information interaction of local channels, and uses sigmoid to convert the interaction results into channel weights to calibrate the channel importance of the feature image F. In this way, a channel attention weight vector Key of size C×1 can be obtained, that is:
[0036] Key={β1,β2,…β c ,…β C}
[0037] =sigmoid(conv1(AvgPool(F))), c∈[0,C) (1)
[0038] Among them, conv1 is a one-dimensional convolution operation, AvgPool is a global average pooling operation, and after the operation, the channel attention weight vector B is obtained, where β c It is the value of the c-th dimension in the weight vector B, corresponding to the weight value of the c-th channel.
[0039] The query branch is a spatial attention mechanism, which performs global maximum pooling and global average pooling on the feature image F to obtain two H×W×1 feature maps. The two feature maps are then concatenated and dimensionality reduced using a convolutional layer. Sigmoid is used to convert the reduced dimensionality result into a spatial weight. Finally, the spatial weight is multiplied by the feature image F to obtain the spatial attention feature.
[0040] Query=sigmoid(conv2(cat[AvgPool(F);MaxPool(F)]))*F (2)
[0041] Among them, cat is the channel splicing operation, MaxPool is the global maximum pooling operation, and conv2 is the two-dimensional convolution operation.
[0042] The Value branch is the input feature image F. After matrix multiplication of the Key branch and the Query branch, the covariance matrix is obtained by normalization using softmax. The obtained covariance matrix is matrix multiplied with the Value branch to obtain the enhanced feature image F', so as to enhance the input feature image with global related information. The feature image F and the enhanced feature image F' are added as the residual structure to avoid network degradation, thereby obtaining the final generated global self-attention feature y of the joint channel spatial attention.
[0043] F′=softmax(Key·Query)·Value (3)
[0044] y=F′+F (4)
[0045] (c) Input the test set images into the network model loaded with trained parameters and output the detection results of the test set images.
[0046] (3) Model training: The learning rate of the present invention is set to 0.00025, and a total of 270,000 training times are performed. The L2 norm is used as the loss function and the Adam optimization method is used, and the learning rate is 0.01.
[0047] (4) Evaluation index: The experiment of the present invention uses mean Average Precision to measure the effect of the algorithm.
[0048] (5) The experiment uses the proposed global self-attention target detection algorithm with joint channel spatial attention. After adding the attention mechanism module, the network's detection result mAP (average precision) = 74.7%, which is 1.2% higher than the original network's detection result mAP = 75.9%.
[0049] Based on the two strategies of channel attention mechanism for channel weight selection and spatial attention mechanism for spatial feature enhancement, this paper designs a global self-attention module that combines channel spatial attention. The main innovations are:
[0050] (1) In order to establish the connection between pixels at a certain distance on the image, this module considers the weighting of all position features, namely spatial, channel, etc., and designs three branches: Key, Query, and Value to combine channel and spatial attention to improve the extraction of feature information.
[0051] (2) The key branch is the channel attention mechanism. In order to reduce the loss of detail information caused by dimensionality reduction of the fully connected layer, the fully connected layer in the original channel space attention mechanism is replaced by a one-dimensional convolution with weight sharing, thereby retaining some detail information and obtaining the channel weight of the corresponding feature image.
[0052] (3) The query branch is a spatial attention mechanism, which uses the spatial attention mechanism to assign different weights to the pixels of each channel of the feature map according to the spatial transformation corresponding to the spatial information in the feature image, thereby extracting the key spatial feature information.
[0053] (4) The Value branch is the input feature image. The principle of the self-attention mechanism based on the covariance matrix is used to improve the extraction of global feature information of the input feature map. The covariance matrix is obtained using the Key and Query branches. The covariance matrix is then multiplied with the Value branch at the pixel level to couple the correlation information between the global pixels of the image. This strategy can effectively and comprehensively improve the feature extraction capability in target detection tasks.
Claims
1. A global self-attention target detection method combined with channel spatial attention, comprising the following steps: The first step is to extract the feature image F; In the second step, a global self-attention module with joint channel spatial attention is designed, and the three branches of Key, Query, and Value are used to further extract features. The feature image F input into the global self-attention module with joint channel spatial attention is assumed to be C×W×H, where C is the number of channels in the feature map, and W and H represent the size of the feature map. The global self-attention module with joint channel spatial attention is divided into three branches, where: (1) The Key branch is a channel attention mechanism, which takes the global average pooling of the feature image F to transform it into a tensor of size C×1×1, uses a one-dimensional convolution operation on the tensor to perform local channel information interaction, and uses sigmoid to convert the interaction result into a channel weight, thereby obtaining a channel attention weight vector Key of size C×1; (2) The query branch is a spatial attention mechanism, which performs global maximum pooling and global average pooling on the feature image F to obtain two H×W×1 feature maps. The two H×W×1 feature maps are then concatenated and dimensionality reduced using a convolutional layer. The sigmoid layer is used to convert the reduced dimensionality result into a spatial weight. Finally, the spatial weight is multiplied by the feature image F to obtain the spatial attention feature. (3) The Value branch is the feature image F; (4) After performing matrix multiplication operation on the Key branch and the Query branch, a normalization operation is performed using softmax to obtain a covariance matrix, and the obtained covariance matrix is subjected to matrix multiplication operation with the Value branch to obtain an enhanced feature image F', so as to enhance the input feature image with global related information. At the same time, the feature image F and the enhanced feature image F' are added as a residual structure to avoid network degradation, thereby obtaining the final generated channel space self-attention feature; In the third step, the data set is used to train the network with the global self-attention module with joint channel spatial attention. The predicted candidate box is obtained through forward propagation. The L2 norm is used as the loss function to calculate the error between the predicted candidate box and the target candidate box and perform back propagation. The ADAM optimizer is used to continuously optimize until the error no longer decreases, thereby obtaining a trained network parameter model.
2. The global self-attention target detection method according to claim 1, characterized in that: The feature image F is extracted through the backbone network deep fusion feature network DLA.
