# PVTReID: A Quick Person Reidentification-Based Pyramid Vision Transformer
## 3 Methods
### Local Feature Clustering Module  
We add a local feature clustering (LFC) branch on the base of the global features. We derive the most discrete local features by calculating the distance between different local features and global features, then optimize them using the cross-entropy loss and triplet loss to separate different local features and improve the features' fine-grained discriminative ability.  
The framework based on PVT has achieved excellent results in ReID due to its powerful global feature extraction ability. However, with the problem of occlusion and posture misalignment, using global feature alone as the standard for distance measurement cannot meet the discrimination needs of difficult samples. Therefore, it is necessary to learn the local features of people in order to improve fine-grained discrimination ability. Stripe features and posture estimation have been widely used in CNN-based methods to extract the fine-grained features of people.  
The feature of an image that PVT-based ReID extracts is \(O_{4}=[f_{1},f_{2},\dots,f_{32}]\), and the global feature f is obtained through the mean operation. In order to obtain fine-grained local features, a straightforward approach is to use the discriminative ability of each local feature, that is, to cluster all local features which have the same person ID in the feature space. While the global feature f obtained after aggregating all local features is clustered as well, it cannot take into account all local features, and there will be situations in which local features cannot be distinguished, as shown in Figure 3a,c.  
In order to solve the problem that certain local features cannot be distinguished, we propose a local feature clustering (LFC) module. By computing the distance of each local feature \(f_{i}\) from the global feature \(f\), we select the local feature with the farthest  
Figure 3: Local feature distribution. We used UMAP (n_neighbors = 10, min_dist = 1) [31] to reduce the dimension of local features: (**a**) without LFC and plot with ID; (**b**) with LFC and plot with ID; (**c**) without LFC and plot with local index; (**d**) with LFC and plot with index. By comparing the distribution of local features with and without the use of LFC, it can be concluded that local features clustered together with different IDs can be dispersed into clusters of the corresponding ID by clustering the most discrete local features.  
distance. Then, through supervised learning we separate the aggregated local feature in Figure 3a,c. The process of selecting the farthest local feature \(f_{m}\) from the global feature \(f\) is shown below:  
\[f_{m}=\underset{f_{i}\in\{f_{i},f_{2},\ldots,f_{32}\}}{\operatorname{argmax}}\| f_{i}-f\|_{2}^{2} \tag{8}\]  
Through Equation (8), we can obtain the most discrete local feature \(f_{m}\). This means that if \(f_{m}\) is clustered with other local features of the same image, the global feature \(f\) obtained by aggregating the local features has better discriminative power.  
As illustrated in Figure 2, another global branch which parallels to the LFC branch obtains \(f\), which is the global feature from the CNN method, using the mean operation. Finally, the loss is computed using the ID loss and triplet loss for the global feature \(f\) and the most discrete local feature \(f_{m}\), respectively, which are then added together using a specific factor. The total training loss is  
\[L=L_{ID}(f)+L_{T}(f)+\eta[L_{ID}(f_{m})+L_{T}(f_{m})]. \tag{9}\]  
During the inference process, the global feature \(f\) and the most discrete local feature \(f_{m}\) with respect to \([f;\eta f_{m}]\) are connected as the ultimate feature representations.