# Multi-Target Detection Algorithm for Fusion Images Based on an Attention Mechanism
## 4 Architecture Improvements for Multi-Target Detection
### Integration of Global Attention Mechanism  
Compared to CBAM and SE, GAM provides a more unified and expressive modeling of both inter-channel and spatial dependencies. While SE focuses solely on channel-wise attention and CBAM applies spatial and channel attention sequentially in a localized manner, GAM employs a deeper and more integrated fusion strategy that better preserves global contextual information. This is particularly advantageous for detecting small or occluded targets, where broad context awareness is essential. Moreover, unlike transformer-based attention mechanisms such as those used in DETR, which rely heavily on computationally intensive self-attention across tokenized inputs, GAM achieves strong global representation with lower computational overhead, making it more suitable for resource-constrained  
Figure 8: Improved feature fusion network.  
Figure 7: Feature extraction model adding new scale features.  
detection scenarios. Therefore, this paper integrates GAM into the detection framework to enhance feature representation and improve overall detection performance. The computation process of GAM is illustrated in Figure 9.  
The feature map \(F_{1}\) input to the network will pass through two attention modules \(M_{c}\) and \(M_{s}\) successively. \(F_{1}\) first passes through \(M_{c}\) to obtain \(F_{2}\), and \(F_{2}\) then passes through \(M_{s}\) to obtain the optimized feature \(F_{3}\). The calculation process is shown in Equations (5) and (6).  
\[F_{2} =M_{c}(F_{1})\varoquie F_{1} \tag{5}\] \[F_{3} =M_{s}(F_{2})\varoquie F_{2} \tag{6}\]  
Among them, \(M_{c}\) and \(M_{s}\) represent attention modules,  represents multiplication, and \(F_{1}\), \(F_{2}\), \(F_{3}\) are input feature maps, intermediate state feature maps and output feature maps respectively.  
The processing flow of the channel attention module on the input is shown in Figure 10. The processing flow is as follows:  
1. For the output feature map \(F_{1}\), the dimension is transformed, and the dimension order changes from \(C\times W\times H\) to \(W\times H\times C\);
2. The multi-layer perceptron is used to introduce nonlinear capabilities, so that the model learns adaptive weights to represent the complex relationship between dimensions. The multi-layer perceptron is an encoder-decoder structure with a reduction ratio of \(r\);
3. Finally, the three-dimensional arrangement is restored to \(C\times W\times H\) and multiplied with the original input feature map element to obtain the final result.  
The input processing flow of the spatial attention module is shown in Figure 11. First, the input feature map is convolved through two \(7\times 7\) convolutional layers to integrate and extract spatial information. These two convolutional layers can capture the features at different spatial scales in the input feature map, thereby enhancing the representation ability of spatial information. Although the maximum pooling operation helps to reduce the complexity of the network, it also causes a lot of information loss. Unlike CBAM attention, in order to retain more information, the GAM spatial attention module does not  
Figure 10: GAM channel attention module.  
Figure 9: GAM attention mechanism module.  
use pooling operations. Therefore, this module may significantly increase the parameters. In order to reduce the parameters while maintaining effectiveness, group convolution with random mixing of channels is used.