# A Multi-Scale Graph Attention-Based Transformer for Occluded Person Re-Identification
## 3 Methods
### Feature Extraction  
In our model architecture, we opted for the Vision Transformer as the backbone network, which is tasked with efficiently extracting high-level semantic features from input images. The introduction of ViT has revolutionized conventional feature extraction methodologies based on Convolutional Neural Networks (CNNs), with it particularly excelling in handling global information and long-range dependencies. The images were segmented into uniformly sized patches and, through setting the stride of the ViT network to slightly less than the patch size, we ensured a degree of overlap between adjacent patches. This process increases information redundancy, enabling the model to capture continuity and detail within local regions to some extent, thereby enhancing its ability to learn fine-grained features while maintaining sensitivity to spatial structures.  
Each patch is regarded as a visual word (visual token). Through linear projection, these patches are mapped into a fixed-dimensional vector space, ensuring encoding of the image's local features. Consequently, each patch is transformed into a D-dimensional vector after projection. A special class token is prepended to all patch vectors, serving as the sequence's start and guiding the model to learn a global feature representation that is conducive to classification. The serialized patch vectors, together with the class token, are then fed into a multi-layer transformer encoder. The self-attention mechanism within the transformer allows for global information exchange among different patches, capturing long-range dependencies. The hierarchical structure, in comparison, bolsters feature expression through deep learning.  
The input image \(\text{x}\in\text{R}^{\text{H}\times\text{W}\times\text{C}}\) is divided into \(N\) patches of size (\(P\), \(P\)). We configured the ViT model with a patch size of \(P\) and a stride of \(S\); consequently, the number of patches into which an image is divided is calculated as follows:  
\[N=(H-P)(W-P)/S^{2}, \tag{1}\]  
where (\(H\), \(W\)) is the resolution of the input image and \(C\) is the number of channels. Subsequently, trainable linear projections are employed to map these patches onto D-dimensional  
Figure 1: The framework of our MSGA-ReID approach is structured as follows: each token output by the transformer is regarded as a node, and a graph structure is established through computing the similarity between the features of these nodes and linking the central node to all other nodes. Subsequently, information from all nodes is aggregated into the central node via multiple instances of our proposed multi-scale graph attention (MSGA) modules. A global channel-wise attention mechanism is employed for weight allocation, integrating class label information with the features of the centralized node to facilitate effective re-identification.  
vectors, with the resultant output recorded as patch embeddings. An additional learnable embedding is incorporated into the input sequence of the transformer, serving as a class token xclass to learn contextual information from other embeddings. Next, a learnable position embedding is added to the input sequence, and the sequence is fed into multiple transformer layers. We express the feature \(Z=[z_{class},z_{1},z_{2},\ldots,z_{N}]\in R^{(N+1)\times d}\) (where \(d\) is the dimension of each feature vector) output by ViT as follows:  
\[Z=ViT(I),\ I\in\Big{[}I_{original},I_{reasing},I_{cropping}\Big{]}. \tag{2}\]