# DMS-YOLOv5: A Decoupled Multi-Scale YOLOv5 Method for Small Object Detection
## 3 Methods
### Attention Mechanism Module  
Small objects are often difficult to extract feature information from due to their small size and low resolution and are easily confused with the background in complex environments. Therefore, attention mechanisms are introduced to solve the problem of background interference, allowing small object information in image features to be better attended to. According to the different dimensions of the input multidimensional information, attention mechanisms can be divided into three types: spatial attention, channel attention, and spatial and channel mixed attention. Among them, the attention mechanism that mixes spatial and channel information achieves a more balanced effect between the two. This paper introduces the CA attention mechanism [32] that mixes spatial and channel information. The CA attention mechanism considers lightweight design principles, reducing both the number of parameters and computational complexity while also solving the problem of long-distance dependency in the spatial dimension. The CA attention mechanism mainly  
Figure 5: Comparison diagram of regular convolution and dilated convolution.  
Figure 6: Receptive field module architecture diagram.  
consists of three parts: information embedding, attention generation, and feature map correction. In the information embedding module, the input feature information is globally average-pooled in both the horizontal and vertical directions. The input feature map with a size of \(\text{C}*\text{H}*\text{W}\) is pooled in the horizontal and vertical directions separately, resulting in feature maps with sizes \(\text{C}*\text{H}*\text{1}\) and \(\text{C}*\text{1}*\text{W}\). The calculation process of global average pooling in the horizontal and vertical directions is shown in Equations (1) and (2), respectively.  
\[z_{c}^{h}(h)=\frac{1}{W}\sum_{0\leq i\leq W}x_{c}(h,i),z_{c}^{h}\in R^{\text{C}* \text{H}*\text{1}} \tag{1}\]  
\[z_{c}^{w}(w)=\frac{1}{H}\sum_{0\leq j\leq H}x_{c}(j,w),z_{c}^{w}\in R^{\text{C}* \text{1}*\text{W}} \tag{2}\]  
The information embedding module structure diagram of the CA attention mechanism is shown in Figure 7.  
The attention generation module concatenates the horizontally feature map \(z^{h}\) and vertically feature map \(z^{w}\) extracted from the information embedding module according to the spatial dimension and inputs them into the activation function after dimension reduction through \(1\times 1\) convolution. Next, the feature maps of the horizontal and vertical directions are separated according to the spatial dimension and input into the Sigmod activation function. Finally, two attention vectors in the horizontal and vertical directions \(f\in R^{\frac{\zeta}{\zeta}*\text{1}*(H+W)}\) are output. The calculation process is shown in Equation (3):  
\[f=\delta\Big{(}F_{1}\Big{(}\Big{[}z^{h},z^{w}\Big{]}\Big{)}\Big{)},f\in R^{ \frac{\zeta}{\tau}*\text{1}*(H+W)} \tag{3}\]  
The feature map correction module expands the dimension of the attention vectors in the horizontal and vertical directions and performs element-wise multiplication between the expanded attention vectors and the feature map vectors to output the final attention feature. The concatenation of the feature information in the horizontal and vertical directions is beneficial for solving the problem of long-range dependencies. The element-wise multiplication operation between the feature information in the horizontal direction  
of the detection heads of various scales in the subsequent steps. At the same time, adding attention mechanisms to the detection head network does not affect the use of pre-trained weight files and does not require complex and time-consuming pre-training processes for network structure changes.