# Multiscale YOLOv5-AFAM-Based Infrared Dim-Small-Target Detection
## 2 Methods
### Multiscale YOLOv5-AFAM
#### 2.2.1 Adaptive Fusion Attention Module  
To address the challenges of low signal-to-noise ratio and susceptibility to background interference for infrared vehicle targets, we propose AFAM, which can be flexibly plugged into the YOLOv5 network. Specifically, AFAM utilizes the adaptive receptive field to enhance the fusion of context information. It achieves performance improvement while reducing computational complexity, making the network suitable for detecting small and weak targets with blurred contours and complex backgrounds, and reducing false positives and missed detection. The AFAM module consists of the Adaptive Receptive Field Channel Attention Module (ACM) and the Fusion Spatial Attention Module (FSM). The former focuses on the region of interest in the input data and aggregates the features of each channel to increase the context information around the target to further expand the receptive field. The latter focuses on determining the location of the target, compressing the spatial dimension  
Figure 2: The architecture of multiscale YOLOv5-AFAM. while fusing the context information around the target. In this paper, they are added to the C3 module of the YOLOv5 backbone network. As shown in Figure 3, a feature map \(\mathbf{F}\in\mathbb{R}^{C\times H\times W}\) is first served as an input to the network. Then, input features are sequentially fed into ACM and FSM to involve channel-wise and spatial-wise attention information. The mathematical formulation is shown in Equation (1). \(\mathbf{F_{A}}\) represents the feature obtained after feature \(\mathbf{F}\) is processed by the ACM module, while \(\mathbf{F^{{}^{\prime}}}\) represents the feature obtained after feature \(\mathbf{F_{A}}\) is processed by the FSM module. \[\mathbf{F_{A}}=f_{A}(\mathbf{F})\otimes\mathbf{F},\quad\mathbf{F^{{}^{\prime}}}=f_{\rm F}(\mathbf{ F_{A}})\otimes\mathbf{F_{A}} \tag{1}\]  
where \(f_{A}(\cdot)\) and \(f_{\rm F}(\cdot)\), respectively, indicates the ACM and FSM module. \(\otimes\) denotes the element-wise multiplication operation. **Adaptive Receptive Field Channel Attention Module:** As shown in Figure 3, ACM first performs a parallel convolution operation with three convolution kernels of size \(1\times 1\), \(3\times 3\), and \(5\times 5\), respectively. Then, output features perform a weighted summation operation to generate the fused feature (\(\mathbf{F_{f}}\)). This fusion process ensures that the network can expand and adjust the receptive field in an adaptive manner. Equation (2) shows the above process. Next, the fused feature passes through Avgpool and Maxpool operations to generate the corresponding contextual descriptors. Finally, Multilayer Perceptron (MLP) is employed for generating the final adaptive receptive field channel attention feature. Equation (3) shows the above process. \[\mathbf{F_{f}}=\sum_{i=1}^{3}(Conv_{i}(\mathbf{F})\times\omega_{i}) \tag{2}\]  
Figure 3: The network structure of AFAM. \[\mathbf{F_{A}}=\sigma(MLP(AvgPool(\mathbf{F_{f}}))+MLP(MaxPool(\mathbf{F_{f}}))) \tag{3}\]  
where \(Conv_{i}(\cdot)\) denotes the convolution operation with three types of kernel size. \(\omega_{i}\) is the \(i\)th weight factor corresponding to each convolution operation. \(\sigma(\cdot)\) denotes \(Sigmoid\) operation. \(AvgPool(\cdot)\) and \(MaxPool(\cdot)\) denote the average-pooling and max-pooling operation, respectively. **Fusion Spatial Attention Module:** In AFAM, we first design ACM to involve channel-wise attention information into features. Then, we further design FSM to explore spatial-wise attention information. As shown in Figure 3, the feature map (\(\mathbf{F_{A}}\)) generated by the ACM first passes through three branches in parallel to extract features with different information (formulated in Equation (4)). Second, three output features are concatenated together and refined by the Conv module (\(f_{C}(\cdot)\)). Third, the output feature map is normalized utilizing the Sigmoid function to obtain the FSM features \(\mathbf{F}^{\prime}\).