## 3 Model and Methods
### Multi-Granularity Module  
Due to the environmental conditions of video image acquisition, many challenges for feature extraction arise in practice, such as occlusion and dislocation. Thus, the effective feature extraction area may be a very small part of a whole image. To improve re-identification accuracy, we explore the feature information in image and video sequences at different levels of granularity and propose an MG module. Given that the overall structure of people can be divided horizontally, we use a horizontal strategy to restructure the token sequence. The rearranged tokens \(z_{n}\)' are divided into global-grained tokens, medium-grained tokens, and fine-grained tokens, according to the size of a window. These tokens share class token \(\Phi^{c}\). For the \(n\)-th frame image in a video sequence \(v\), the input token sequence of the last layer (layer \(l\)) is set to \(z_{n}\,^{l-1}=[\Phi^{c}\,_{n}\,^{l-1},\,F_{n1}\,^{l-1},\,F_{n2}\,^{l-1},\, \ldots,\,F_{nN}\,^{l-1}]\). We extract \(N\) feature embeddings \(z_{n}=\{F_{n1}\,^{l-1},\,F_{n2}\,^{l-1},\,\ldots,\,F_{nN}\,^{l-1}\}\) and rearrange them according to the original corresponding positions in the image to obtain \(z_{n}\in\mathbb{R}^{H\times(W\times p)}\):  
\[z_{n}=\{F_{n1}\,^{l-1},F_{n2}\,^{l-1},\cdots,F_{nN}\,^{l-1}\}\overset{\text{ Rearrange}}{\rightarrow}z_{n}\,^{\prime}= \begin{bmatrix}F_{n1}\,^{l-1}&F_{n2}\,^{l-1}& \cdots&F_{n(W\times p)}\,^{l-1}\\ F_{n(W\times p+1)}\,^{l-1}&F_{n(W\times p+2)}\,^{l-1}&\cdots&F_{n(2\times W \times p)}\,^{l-1}\\ \vdots&\vdots&\ddots&\vdots\\ F_{n((H-1)\times W\times p+1)}\,^{l-1}&F_{n((H-1)\times W\times p+2)}\,^{l-1}& \cdots&F_{nN}\,^{l-1}\end{bmatrix}  \tag{6}\]  
Figure 3: Schematic diagram of correlation-adaptive partitioning of feature embeddings. For global-grained tokens, we use a window of size \(H\times(W\times p)\) to partition \({z_{n}}^{l}\) into a whole. \(\Phi^{c}{}_{n}^{l-1}\) and \({z_{n}}^{l}\) are flattened together along the horizontal direction and then spliced to form the global-grained token sequence \({z_{glo,n}}^{l-1}=[\Phi^{c}{}_{n}^{l-1},\,{F_{n}}_{1}^{l-1},\,{F_{n}}_{2}^{l-1}, \,\ldots,\,\,{F_{nN}}^{l-1}]\,{z_{glo,n}}^{l-1}\in\mathbb{R}^{(1+N)\times c}\). After \(l_{glo}\) layers of backbone transformer operations, the final output global-grained token sequence is obtained: \({z_{glo,n}}^{l}=[\Phi^{c}{}_{n}^{l},\,{F_{n}}_{1}^{l},\,{F_{n}}_{2}^{l},\, \ldots,\,{F_{nN}}^{l}]\), \({z_{glo,n}}^{l}\in\mathbb{R}^{(1+N)\times c}\). Following previous studies, we use the class token as feature representations of the token sequence. For the video sequence \(v\), the set of global-grained tokens from \(l\)-frame images can be obtained as follows:  
\[{z_{glo}}=\left\{\Phi^{c}{}_{glo,1}^{l},\,\Phi^{c}{}_{glo,2}^{l},\,\ldots,\, \Phi^{c}{}_{glo,l}^{l}\right\} \tag{7}\]  
For medium-grained tokens, we use a window of size \((H/2)\times(W\times p)\) to divide \({z_{n}}^{l}\) into two parts. \(\Phi^{c}{}_{n}^{l-1}\) is combined with each of the two parts and, after expansion, two groups of medium-grained token sequences, \({z_{\text{med,}n}}^{l-1}\) and \({z_{\text{med,}n}}^{l-1}\), are obtained. The first medium-grained token sequence is \({z_{\text{med,}n}}^{l-1}=[\Phi^{c}{}_{n}^{l-1},\,{F_{n}}_{1}^{l-1},\,\,{F_{n} }_{2}^{l-1},\,\ldots,\,\,{F_{n,(N/2)}}^{l-1}]\). Through the \(l_{\text{med}}\) layer operation of the backbone transformer, class tokens learn the relationship and feature information between medium-grained tokens. Finally, two groups of medium-grained token sequences, \({z_{\text{med,}n}}^{l}\) and \({z_{\text{med,}n}}^{l}\), are outputs. We use a class token as the feature representation of the token sequence.