# Multiscale YOLOv5-AFAM-Based Infrared Dim-Small-Target Detection
## 2 Methods
### Multiscale YOLOv5-AFAM
#### 2.2.3 Improved Multiscale Fusion Structure  
The contrast ratio of vehicle targets in infrared images is relatively low, and there are scale and grayscale differences among intra-class targets in the dataset. There is feature similarity between different categories of targets, all of which increase the difficulty of detection. In response to the above issues, we add shallow feature maps to feature aggregation to improve the detection performance of infrared dim and small vehicles.  
With the deepening of the neural network and the increase in downsampling times, the semantic information obtained by this feature layer is more abundant, but the texture information of the image will be reduced. In this paper, the infrared dim small target occupies approximately \(20\times 20\) pixels in the \(640\times 640\) infrared image. Therefore, it is not conducive to the detection of dim and small targets. In response to the above issues, we involve feature maps in shallow layers to improve the detection performance of dim and small targets. As shown in Figure 5, we propose three improved multiscale fusion structures, which are \"four-scale feature fusion\", \"four-scale shallow feature fusion\", and \"three-scale shallow feature fusion\".  
In order to enhance the contour information and geometric information of the target, we propose a \"four-scale feature fusion\" structure, which incorporates 4 times downsampling features on the basis of the original feature extraction network. This design can make the network facilitate the detection of infrared dim small targets, and the improved structure is shown in Figure 5a. To further analyze the effect of scale variation on the detection effect, we add a new 2 times downsampling features in the \"four-scale shallow feature fusion\" structure. In this structure, \(\{2,4,8,16\}\) times downsampling features are fused together to keep the texture feature of dim small targets. The structure is shown in Figure 5b. For performance comparison and analysis, we propose the \"three-scale shallow feature fusion\" structure. Compared to \"four-scale shallow feature fusion\" structure, it removes 2 times downsampling and leaves \(\{4,8,16\}\) times downsampling features for fusion.  
In this paper, feature fusion methods are selected according to the size differences of the detected targets. As 4 times downsampling features are more suitable for detecting small targets, they are incorporated into the feature fusion for all three structures. Based on the improvement in network detection accuracy, an attempt is made to incorporate the 2 times downsampling feature. However, involving the 2 times downsampling feature will boost the computation and memory cost. Therefore, we remove this feature after making a trade-off between performance improvement and cost. When using 32 times downsampling features, the target is easily missed with a very small percentage of the feature map, so this scale was removed. Based on the above-mentioned analysis, we select  
Figure 5: Improved multiscale fusion network (**a**) Four-scale feature fusion; (**b**) Four-scale shallow feature fusion; (**c**) Three-scale shallow feature fusion.  
\(\{4,8,16\}\) times downsampling features (Figure 5c) to solve the problem of infrared dim-small-target detection, which can achieve the best detection effect under acceptable cost.