# Pedestrian Re-Identification Algorithm Based on Unmanned Aerial Vehicle Imagery
## 3 Improvement of Transformer-Based Pedestrian Re-Identification Algorithm
### Non-Local Attention Mechanism  
In UAV multi-view scenarios, pedestrians often exhibit complex postures. This results in the dispersion of features from different body parts across the image. Effectively capturing the global relationships among these dispersed features is essential for accurate pedestrian detection. Although the Transformer's self-attention mechanism is highly effective in capturing global information, it relies on local neighborhoods or fixed context windows. This reliance limits its ability to fully leverage dependencies between distant regions in the image. To overcome this limitation, the non-local attention mechanism is integrated into the global branch of the Transformer model. This enhancement improves the model's capability to capture and aggregate global dependencies across arbitrary positions in the image. Consequently, it enables a more comprehensive understanding of the global context.  
Figure 4: Single-layer graph convolution.  
The essence of the non-local attention mechanism lies in its ability to capture correlations between arbitrary regions of the image. This capability is crucial for achieving a holistic understanding of pedestrians. The mechanism generates weighted global features by calculating interactions between different locations in the feature map. This process enhances the model's ability to effectively capture and utilize global information.  
In the implementation, the input features are first passed through three \(1\times 1\) convolutional layers to generate three different feature maps: \(\theta\), \(\phi\), and \(\gamma\). The similarity matrix \(F\) between \(\theta\) and \(\phi\) is computed, typically using the dot product: \(f(\theta_{i},\phi_{j})=\theta_{i}^{\intercal}\phi_{j}\), where \(i\) and \(j\) represent different positions in the feature map. The similarity matrix is then normalized using the softmax function to ensure that the sum of each row equals 1:  
\[softmax(f(\theta_{i},\phi_{j}))=\frac{exp(f(\theta_{i},\phi_{j}))}{\sum_{k}exp( f(\theta_{i},\phi_{k})} \tag{3}\]  
A weighted sum of \(\gamma\) is then computed using the normalized similarity matrix as weights:  
\[y_{i}=\sum_{j}exp(f(\theta_{i},\phi_{j})\gamma_{j} \tag{4}\]  
Finally, the output feature maps are concatenated with the original input feature maps through a residual connection, as described by \(Z=X+Y\). This residual connection preserves the original features and enhances the model's representational capacity. The dimensionality of the output feature map remains consistent with that of the input feature map. This consistency enables the model to capture local information within the image. Additionally, the model integrates global contextual information through the non-local attention mechanism. Consequently, this integration improves the model's ability to handle multi-view variations in UAV footage. The structure is illustrated in Figure 5.  
Figure 5: Non-attentive mechanism module.  
Although the non-local attention mechanism introduces additional computational overhead, it effectively integrates global information by capturing dependencies between distant regions within pedestrian images. This integration significantly enhances the overall structural detection capability. Additionally, it provides substantial advantages for pedestrian re-identification across multiple viewpoints in UAV footage.