# Rethink Motion Information for Occluded Person Re-Identification
## 3 Methodology
### Motion-Aware Transformer  
In Figure 2c, the motion-aware transformer module takes the aforementioned visual tokens \(\mathbf{VT}_{L}\) from the visual adapter module to generate corresponding motion tokens \(\mathbf{MT}_{L}\). It consists of a standard cross-attention layer [31], a multi-head self-attention layer, and a feed-forward network layer. The cross-attention layer aims to extract foreground human body parts from the \(\mathbf{VT}_{L}\) with the learnable queries. Next, the self-attention blocks further incorporate the local context of human parts into separate part prototypes. The feed-forward network (FFN) part, consisting of two fully connected layers, introduces non-linearity and produces attention output \(\mathbf{MT}_{L}\). To learn valid and effective queries, we elaborate a motion consistency task and corresponding loss function for the training process of the motion-aware transformer. To make it easier to explain the main steps of the motion consistency task, we choose two images from different views as input in Figure 3. Note that the motion tokens are independently generated from the consistency task, and consequently, the proposed motion-aware transformer module can be used for a single image at inference time. For the two images (i.e., source and target), the MLP-1 utilizes the motion tokens \(\mathbf{MT}_{L}\) to obtain the segmentation results of human parts \(\mathcal{M}_{S,part}\) and \(\mathcal{M}_{T,part}\). The output of MLP-1 (\(\mathcal{M}_{part}\in\mathbb{R}^{N\times H_{D}\times W_{D}}\)) represents different probability distributions for the \(N\) different human parts. Here, the number of human parts divided in the motion-aware transformer is determined by the length \(N\) of learnable queries; \(H_{D}\) and \(W_{D}\) mean the height and width dimension of segments. In Figure 3, we set \(N=10\), and obtain ten probability distributions for the ten human parts. Formally, let \(\mathcal{M}_{part}^{k}\) be the \(k^{th}(k\in[0,\cdots,N-1])\) segment of human parts \(\mathcal{M}_{part}\). In the probability distribution \(\mathcal{M}_{part}^{k}\), we define the highest probability point in the distribution as the key point \(p_{part}^{k}\). The key point, \(p_{part}^{k}=(i,j);i\in[1,H_{D}],j\in[1,W_{D}]\), represents the location associated with the \(k^{th}\) segment of human parts. Hereby, for the source image and target image, we can both extract ten key points of different human parts according to the segmentation results of MLP-1. We design the MLP-2 to describe the motion of all points in the segments of human parts \(\mathbf{M}_{part}\). The output of MLP-2 represents an affine transformation [24], which is used to approximate the optical flow \(\mathcal{F}\) of every segment of human parts. Here, we assume that the motion of each segment follows an affine model [24], this implies that there exists \(\mathbf{A}\in\mathbb{R}^{2\times 2}\) and \(\mathbf{\beta}\in\mathbb{R}^{2}\) such that:  
Figure 3: The explanation of the motion consistency task. For a more concise presentation of the motion consistency task, we omitted two input images from different views here. \[\forall z\in\mathcal{M}_{part}^{k},\ \mathcal{F}^{k}(z)=\mathcal{A}z+\beta, \tag{1}\]  
Here, \(z\) is the location point of the \(\mathcal{M}_{part}^{k}\). After the output of MLP-2 explicitly approximates the affine parameters \(\mathcal{A}\) and \(\beta\) for our given source image (S) and the target image (T), we can obtain \(F\) with the following equation:  
\[\forall z\in\mathcal{M}_{part}^{k},\ \mathcal{F}^{k}(z)=p_{S,part}^{k}+\mathcal{A }_{S}^{k}{\mathcal{A}_{T}^{k}}^{-1}(z-p_{T,part}^{k}) \tag{2}\]  
where \(p_{S,part}^{k}\in\mathbb{R}^{2}\) and \(p_{T,part}^{k}\in\mathbb{R}^{2}\) are the selected key points of the source image and the target image, respectively. \(\mathcal{A}_{S}^{k}\) and \(\mathcal{A}_{T}^{k}\) are the predicted motion descriptions from the MLP-2. In other words, the optical flow \(\mathcal{F}\) can be approximated by an affine transformation corresponding to each segmented part.