# A Lightweight Uav Swarm Detection Method Integrated Attention Mechanism
## 3 Materials and Methods
### Backbone Network  
CSPDarkNet [35] is used as the backbone of our UAV swarm detection model, consisting mainly of convolution layers and a CSP structure, as shown in Table 2. First, a 640 \(\times\) 640 RGB three-channel image is input into the network, and the image size and the number of channels are adjusted through Focus. Then, four stacked Resblock body modules are used for feature extraction. In the last Resblock body module, the image is processed through the SPP module; that is, the max pooling operation with different kernel sizes is used for feature extraction to improve the receptive field of the network. The final output of CSPDarkNet is the feature maps of the 2 nd, 3 rd, and 4 th Resblock body modules, with the shapes of 80 \(\times\) 80 \(\times\) 256, 40 \(\times\) 40 \(\times\) 512, and 20 \(\times\) 20 \(\times\) 1024, respectively.  
In the Resblock body module, the CSPLayer is similar to the residual structure. The input first passes through convolutional layers with a kernel size of 1\(\times\)1 and 3\(\times\)3 for n times, then the result and the original input are concatenated as output, as shown in Figure 2a. In order to further improve the detection of UAV swarm targets, referring to the MobileNet V3 model [29], a Squeeze-and-Extraction (SE) module [6] is introduced into the CSPLayer structure, as shown in Figure 2b. The UAV detection model uses SiLU as the activation function. SiLU has the characteristics of no upper bound, with a lower bound and smooth and non-monotone functions. It can converge faster during training and its formula is as follows:  
\[SiLU(x)=x\text{-}\textit{sigmoid}(x), \tag{1}\]  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Module** & **Structure** & **Output** & **Valid Output** \\ \hline Inputs & Inputs & 640 \(\times\) 640 \(\times\) 3 & \\ Focus & Focus & 320 \(\times\) 320 \(\times\) 12 & \\ Conv2D-BN-SiLU & Conv2D-BN-SiLU & 320 \(\times\) 320 \(\times\) 64 & \\ \hline \multirow{2}{*}{Resblock body1} & Conv2D-BN-SiLU & 160 \(\times\) 160 \(\times\) 128 & \\  & CSPLayer & 160 \(\times\) 160 \(\times\) 128 & \\ \hline \multirow{2}{*}{Resblock body2} & Conv2D-BN-SiLU & 80 \(\times\) 80 \(\times\) 256 & \\  & CSPLayer & 80 \(\times\) 80 \(\times\) 256 & Output 1 \\ \hline \multirow{2}{*}{Resblock body3} & Conv2D-BN-SiLU & 40 \(\times\) 40 \(\times\) 512 & \\  & CSPLayer & 40 \(\times\) 40 \(\times\) 512 & Output 2 \\ \hline \multirow{2}{*}{Resblock body4} & Conv2D-BN-SiLU & 20 \(\times\) 20 \(\times\) 1024 & \\  & SPPBottleneck & 20 \(\times\) 20 \(\times\) 1024 & Output 3 \\ \cline{1-1}  & CSPLayer & 20 \(\times\) 20 \(\times\) 1024 & \\ \hline \hline \end{tabular}
\end{table}
Table 2: The structure of CSPDarkNet.  
Figure 1: Overall structure of object detection model.  
Specifically, the SE module generates different weight coefficients for each channel by using the correlation between feature channels, multiplies them with the previous features, and adds them to the original features to enhance the features. As shown in Figure 3, the detailed process of the SE attention mechanism is as follows: First, the extracted feature \(X\in\mathbb{R}^{H^{\prime}\times W^{\prime}\times C^{\prime}}\) is mapped to \(U\in\mathbb{R}^{H\times W\times C}\) through the conversion function \(F_{tr}\). Then, the global information of each channel is represented with a channel characteristic description value through global average pooling \(F_{sq}(\cdot)\); and then the channel characteristic description value is adaptively calibrated by \(F_{ex}(\cdot\,,\,W)\) to make the weight value more accurate. Finally, the enhanced feature is obtained by multiplying the weight value and the original feature through \(F_{scale}(\cdot\,,\,\,\cdot)\).