# A Semantic Segmentation Dataset and Real-Time Localization Model for Anti-UAV Applications
## 4 ThinDyUNet Realtime Segmentation Model  
The architecture of the proposed model retains the general structure of the U-Net framework but incorporates significant modifications to reduce the model size and improve its ability to effectively process VL and IR images. In the original U-Net, the encoder's shallowest layer has 64 channels, and the number of channels doubles after each convolutional block in the encoder's downsampling path. That method is designed for complex data such as multi-label segmentation tasks that trained on datasets like ImageNet or COCO; it relies on a large number of parameters and diverse channel combinations to capture a wide range of semantic information. However, such a level of complexity is not required for simpler, single-class tasks. In our case, the task mainly focuses on segmenting a single UAV, which inherently requires less representational power. Therefore, our proposed model adopts a more efficient architecture by using fixed 64 channels across all convolutional blocks in both the encoder and decoder. This design significantly reduces the number of parameters to approximately 1.3 million, making it computationally efficient and well-suited for real-time inference. Figure 4: Heatmap of segmentation mask position distribution in the UAV semantic segmentation dataset. (**a**) Position distribution in training set. (**b**) Position distribution in validation set. (**c**) Position distribution in test set. Figure 5: Distribution of mask scale in the dataset. (**a**) Mask scale distribution in training set. (**b**) Mask scale distribution in validation set. (**c**) Mask scale distribution in test set. In the encoder, the conventional double convolutional layers are replaced by attention-based dynamic convolution layers. This mechanism enables the network to adapt its feature extraction dynamically based on the input modality. The attention mechanism is based on the squeeze-and-excitation (SE) method, which consists of two main steps. The squeeze step performs global average pooling (GAP) over the spatial contextual information. Followed by the excitation step, where the descriptor is passed through a fully connected layer or \(1\times 1\) convolutions and then activated by a non-linear function (e.g., sigmoid) to generate attention weights. These weights are used to recalibrate the input channels by scaling them accordingly. In dynamic convolution, the SE method of attention applied not to channel-wise features but to a set of convolution kernel parameters. The input feature map first undergoes global pooling to generate the descriptor and is then processed through two convolutions and a SoftMax function to produce a set of attention scores, as shown in Figure 6. These scores represent the importance of each in a predefined set of N kernels. A dynamic kernel is computed as the weighted sum of these kernels, using the attention scores as weights. This kernel then applied to the features with standard convolution followed by normalization and activation to allow the network to converge more efficiently with better gradient flow. \[X\in\mathbb{R}^{C\times H\times W} \tag{1}\]  
\[z=Conv_{1\times 1}^{(2)}(Conv_{1\times 1}^{(1)}(GAP(X)))\in\mathbb{R}^{N} \tag{2}\]  
\[\alpha=Softmax(z),\alpha\in\mathbb{R}^{N},\sum_{i=1}^{N}\alpha_{i}=1 \tag{3}\]  
\[K_{dyn}=\sum_{i=1}^{N}\alpha_{i}K_{i} \tag{4}\]  
\[Y=LeakyReLU(GroupNorm(K_{dyn}\times X)) \tag{5}\]  
The dynamic convolution mechanism enables the model to adaptively generate task-relevant kernels conditioned on the input, making it particularly effective for processing data with more than one modality. Given an input feature map \(X\in\mathbb{R}^{C\times H\times W}\), the process begins by extracting a global representation through global average pooling (GAP), followed by pointwise convolution. Those layers act as a fully connected network to produce a latent vector \(z\), where N corresponds to the number of predefined candidate convolution kernels.