# A Lightweight Uav Swarm Detection Method Integrated Attention Mechanism
## 3 Materials and Methods
### Model Training
#### 3.6.1 Data Augmentation  
Data augmentation is a means of expanding the dataset in computer vision. The approach enhances the image data to compensate for the problem of insufficient training dataset images and achieve the purpose of expanding the training data. As the UAV swarm dataset UAVSwarm used for the experiment has few training samples and repetitive scenes, the Mosaic and Mixup algorithms are used in the image data preprocessing process in order to increase the diversity of training samples and enrich the background of the target, to avoid, as far as possible, the network falling into overfitting during the training process and improve the recognition accuracy and generalization ability of the network model.  
The enhancement effect of the Mosaic algorithm is shown in Figure 8. First, the four images are randomly cut, scaled, and rotated, and then they are spliced into a new image as the input image for model training. It should be noted that the image during processing contains the coordinate information of the bounding box of the target, so the new image obtained also contains the coordinate information of the bounding box of the UAV. The advantage of this is that, on the one hand, the size of the object in the picture is reduced to meet the requirements for small object detection accuracy, and, on the other hand, the complexity of the background is increased, so that the UAV swarm detection model has better robustness toward complex backgrounds.  
The Mixup algorithm was originally used for image classification tasks. The core idea is to randomly select two images from each batch and mix them up to generate new images in a certain proportion. The Mixup algorithm is more lightweight than Mosaic, requiring  
Figure 8: The enhancement effect of Mosaic.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Method** & **Parameters** &
\begin{tabular}{c} **Computational** \\ **Amount** \\ \end{tabular} & **Ratio** \\ \hline standard convolution & \(D_{k}\times D_{k}\times C\times N\) & \(\begin{matrix}D_{k}\times D_{k}\times C\times N\times\\ W\times H\end{matrix}\) & 1 \\ \hline depthwise separable & \(D_{k}\times D_{k}\times C+\) & \(D_{k}\times D_{k}\times C\times W\times\) & \\ convolution & \(C\times N\) & \(H+C\times N\times W\times H\) & \(\frac{1}{N}+\frac{1}{D_{k}{}^{2}}\) \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparison of the two convolution methods.  
only minimal computational overhead, and can significantly improve the operation speed of the model. Its mathematical expression is as follows:  
\[\begin{cases}\widetilde{x}=\lambda x_{i}+(1-\lambda)x_{j}\\ \widetilde{y}=\lambda y_{i}+(1-\lambda)y_{j}\,,\\ \lambda e[0,\,1]\end{cases} \tag{3}\]  
where \((x_{i},y_{i})\) and \((x_{j},y_{j})\) are two randomly selected samples and their corresponding labels, \((\widetilde{x},\widetilde{y})\) are the newly generated samples and their corresponding labels that will be used to train the neural network model, and \(\lambda\) is a fusion coefficient. It can be seen from Formula (3) that Mixup essentially fuses two samples through a fusion coefficient. The enhancement effect of the Mixup algorithm is shown in Figure 9.