A Contrastive Learning Unsupervised Person Re-ID Method Based on Transformer and Fusion Clustering
Through the fusion clustering and multi-level contrastive learning method based on Transformer, the problem of hyperparameter dependence and inaccurate clustering agents in unsupervised pedestrian re-identification is solved, automatic identification and efficient feature extraction are achieved, and cost and time expenses are reduced.
Patent Information
- Application Number
- CN202411163106.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-08-23
AI Technical Summary
Existing unsupervised person re-identification methods rely on hyperparameter-sensitive clustering algorithms and inaccurate clustering agents, which affects model performance, and it is difficult for unsupervised methods to effectively extract discriminative features from unlabeled data.
A Transformer-based fusion clustering method is used to generate pseudo labels through DBSCAN clustering, combined with a multi-level contrastive learning module, using difficult sample mining and memory update strategies to reduce the impact of hyperparameter dependence and cluster shape on the model.
It realizes automatic pedestrian recognition, reduces the workload of manual labeling, saves manpower and time costs, improves the stability and generalization ability of the model, and can effectively extract discriminative features from unlabeled data and train the model.
Smart Images

Figure CN118692114B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to an unsupervised pedestrian re-identification method based on contrastive learning of Transformer and fusion clustering. Background Art
[0002] With the continuous development of deep learning technology, supervised person re-identification methods have achieved satisfactory performance on public datasets. However, supervised person re-identification is data-driven and often relies on a large amount of labeled data to train the model. It requires a lot of manpower and time to annotate the data, which greatly limits the scalability and versatility of supervised methods. Therefore, more and more research is directed to unsupervised person re-identification, which directly extracts discriminative features from easily collected unlabeled data and trains the model. This has greater deployment potential in real-world scenarios. Existing related technologies can be divided into two categories: unsupervised person re-identification and contrastive learning methods. (1) In terms of unsupervised person re-identification algorithms, many existing unsupervised person re-identification methods generally first use clustering algorithms to cluster the unlabeled training set images, then assign the same pseudo-label to instances in the same cluster, and then use the generated pseudo-label to train the model in a supervised manner. However, clustering algorithms are dependent on hyperparameters. Inappropriate hyperparameters have a great impact on the performance of the model, and a large number of experiments are required to find the appropriate hyperparameters. (2) In contrastive learning methods, the selection of clustering agents is crucial. Inaccurate agents will lead the model to update in the wrong direction, and the clusters after clustering have different shapes. It is unreliable to directly use the mean feature as a clustering agent. The selection of clustering agents is crucial in contrastive learning. Inaccurate agents will lead the model to update in the wrong direction, and the clusters after clustering have different shapes. It is unreliable to directly use the mean feature as a clustering agent. Summary of the invention
[0003] Purpose of the invention: The purpose of the present invention is to provide an unsupervised pedestrian re-identification method based on contrastive learning of Transformer and fusion clustering to solve the problems existing in the background technology.
[0004] Technical solution: The present invention discloses a method for unsupervised person re-identification based on contrastive learning of Transformer and fusion clustering, comprising the following steps:
[0005] (1) The surveillance camera captures the pedestrian video and uploads it to the cloud server, which tracks the pedestrian and crops the image;
[0006] (2) Use the Transformer network to extract pedestrian image features;
[0007] (3) The fusion clustering module performs fusion clustering on the extracted image features;
[0008] (4) Use a multi-level contrastive learning module to obtain the relationship between instances.
[0009] Furthermore, step (1) is as follows: the Faster RCNN algorithm is used to detect pedestrians, and pedestrian detection frames are drawn, and pedestrian images are uniformly cropped into 256×256 pixel size to form a gallery set.
[0010] Furthermore, step (2) is as follows: First, the input image is processed by the convolutional layer of batch normalization IBN to generate a feature map ; Where C represents the number of channels of the image, H represents the height of the image, and W represents the width of the image; then the image features are divided into P non-overlapping blocks, and each block is projected into a D-dimensional feature as an embedding tag; and an additional learnable class token is added to the input sequence and used as the input of the Transformer network; finally, it is sent to a network containing L Transformer layers, each of which consists of a multi-head attention MSA and a multi-layer perception MLP module; the final output of the Transformer network is recorded as .
[0011] Furthermore, step (3) is as follows: use the DBSCAN clustering algorithm to generate pseudo labels for model training; in the clustering stage, use different hyperparameters to run the DBSCAN clustering algorithm to obtain multiple clustering results, and fuse the multiple clustering results; assign the same pseudo label to pedestrian images belonging to the same cluster; and finally obtain a new labeled dataset, which is represented as ;in, The label representing the cluster, is the number of instances, Q is the number of clusters; where the hyperparameter It is 0.45, 0.5, 0.55, and 0.6.
[0012] Furthermore, step (4) is as follows: create a memory library to store cluster features and instance features, and use the instance-level contrast loss HIL based on difficult sample mining and the cluster-level contrast loss MUL based on the memory update strategy for training; the loss function formula is as follows:
[0013] ;
[0014] in, represents instance-level contrast loss HIL, It represents the cluster-level contrast loss MUL, and the parameter is a balancing factor between 0 and 1;
[0015] The definition of instance-level contrast loss HIL based on difficult sample mining is as follows:
[0016] ;
[0017] Among them, q is the query instance feature, P represents the number of sample pairs, is the temperature hyperparameter, is the instance feature with the smallest cosine similarity ranking within the same pseudo-label, is the difficult negative instance feature, corresponding to the i-th cluster, and its cosine similarity ranks highest;
[0018] ;
[0019] ;
[0020] in, represents the kth positive sample in the cluster to which q belongs, represents the kth sample in the i-th cluster, q is the query instance feature, and k represents all integers ranging from 1 to K;
[0021] The definition of cluster-level contrast loss MUL based on memory update strategy is as follows:
[0022] ;
[0023] Among them, q is the query instance feature, is the proxy feature of cluster i; To query the proxy features of the cluster to which instance q belongs, is the temperature hyperparameter.
[0024] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages: it uses an automated method to identify pedestrians, reducing the workload of manual visits and investigations, and unsupervised pedestrian re-identification extracts discriminant features from easily collected unlabeled data and trains models, saving a lot of manpower and time costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 is a flow chart of the present invention;
[0026] Figure 2 It is a network structure diagram of the unsupervised person re-identification framework based on contrastive learning of Transformer and fusion clustering of the present invention;
[0027] Figure 3 is a schematic diagram of instance-level contrastive learning based on difficult sample mining of the present invention;
[0028] Figure 4 It is a schematic diagram of cluster agent selection of the present invention; DETAILED DESCRIPTION
[0029] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0030] like Figure 1 As shown, the embodiment of the present invention provides a contrastive learning unsupervised pedestrian re-identification method based on Transformer and fusion clustering, comprising the following steps:
[0031] S1's multiple networked cameras form a monitoring network with extensive coverage. Pedestrian video data captured by all cameras is transmitted in real time and stored in the cloud server to provide support for subsequent analysis and processing.
[0032] S2 pre-processes the video data in the cloud server, uses the Faster RCNN algorithm to detect pedestrians, draws pedestrian detection frames, and uniformly crops them into pedestrian images with a size of 256×256 pixels. These pedestrian data constitute a gallery set.
[0033] S3 Figure 2 As shown in the figure, the pedestrian images in the gallery are input into the designed unsupervised pedestrian re-identification neural network framework, and the corresponding feature vectors are extracted using the Transformer network; first, the input image is processed by the convolution layer of the batch normalization IBN to generate a feature map ; (Use IBN-Net-based convolution to replace the previous ordinary convolution in ViT to further improve training stability and generalization ability.) Among them, C represents the number of channels of the image, H represents the height of the image, and W represents the width of the image; then the image features are divided into P non-overlapping blocks, and each block is projected into a D-dimensional feature as an embedded tag; and an additional learnable class token is added to the input sequence as the input of the Transformer network; finally, it is sent to a network containing L Transformer layers, each layer of which is composed of multi-head attention MSA and multi-layer perception MLP modules; the final output of the Transformer network is recorded as .
[0034] S4 performs fusion clustering on the extracted image features. Values will produce different clusters, using multiple Run the DBSCAN algorithm to merge multiple clustering results into a unique, more robust final result. Effectively handle noise samples, assign samples in denser areas to the same cluster, and reduce dependence on the hyperparameter ε. Specifically, the present invention uses 4 Run DBSCAN clustering with the following values: 0.45, 0.5, 0.55, 0.6. After each clustering, retain the outliers, that is, The samples detected as outliers in the cluster are still retained as outliers at 0.5, 0.55, and 0.6, and are not placed in other clusters. This can effectively filter out noise samples.
[0035] In order to further distinguish easily confused sample pairs and deeply explore the relationship between instances, S5 introduces instance-level contrast loss (HIL) based on difficult sample mining. First, an instance-level memory library is constructed to store instance features, including Instance features, including P pseudo-identity labels and K instances for each identity label. Specifically, the pseudo-identity label to which instance q belongs is found through distance measurement, and the positive sample with the farthest distance is mined as a difficult positive sample by calculating the similarity between instance q and all instances in its cluster. Different from the traditional difficult triplet loss, we have a loss of 10 ... negative samples, where for other pseudo-label clusters, the instance closest to instance q is selected as the negative sample for contrastive learning. Figure 3 As shown, the relationship between the query instance and all clusters is considered to fully explore the relationship information between instances.
[0036] For the query instance q, construct P sample pairs, including a positive sample pair and The instance-level contrast loss (HIL) based on difficult sample mining is defined as follows:
[0037] ;
[0038] Among them, q is the query instance feature, P represents the number of sample pairs, is the temperature hyperparameter, is the instance feature with the smallest cosine similarity ranking within the same pseudo-label, is the difficult negative instance feature, corresponding to the i-th cluster, and its cosine similarity ranks highest;
[0039] ;
[0040] ;
[0041] in, represents the kth positive sample in the cluster to which q belongs, represents the kth sample in the i-th cluster, q is the query instance feature, and k represents all integers ranging from 1 to K.
[0042] like Figure 4As shown in the figure, when the clustering algorithm generates non-spherical clusters, the average feature cannot represent the cluster proxy well, and may even fall into other clusters, which will lead to the wrong update direction and reduce the performance of the model. In order to overcome the above problems, a cluster-level contrast loss (MUL) based on memory update strategy is proposed. The main idea is to randomly select an instance feature in the cluster as the proxy in the cluster memory library, forcing the instance to be close to its cluster proxy and away from other proxies.
[0043] Specifically, first, create a cluster-level memory library And initialize the memory bank with randomly selected instance features from each cluster ClusterNCE loss is then used to calculate the cluster-level contrast loss to force instances to be close to their cluster agents and away from other agents. The formula is as follows:
[0044] ;
[0045] Among them, q is the query instance feature, is the proxy feature of cluster i; To query the proxy features of the cluster to which instance q belongs, is the temperature hyperparameter.
[0046] Initialize the centroids of the clusters Then store them in In the example, the features of randomly selected instances in the cluster are used for initialization. , for pseudo-labels Randomly selected instance features In each iteration, directly The cluster agent is updated to , the formula is as follows:
[0047] .
[0048] Evaluation Metrics: Training does not include true identity labels. The effectiveness of the JCL method is evaluated using an established training / test split and evaluation protocol. Two standard metrics are used, namely cumulative matching features (CMC) and mean average precision (mAP). The Transformer backbone network used in this paper is based on the TansReID-SSL model, which has 12 Transformer layers. The backbone network is pre-trained on the large-scale unlabeled dataset LUPerson. This paper calculates the Jaccard distance and uses the DBSCAN clustering algorithm to cluster the k nearest neighbors, where Each mini-batch contains 256 images, representing 32 different pedestrians, and each pedestrian has 8 image samples. The SGD optimizer is used for 50 iterations with a momentum of 0.9. The initial learning rate is set to , the learning rate is divided by 10 every 20 iterations. The entire algorithm is implemented in PyTorch.
Claims
1. A contrastive learning unsupervised person re-identification method based on Transformer and fusion clustering, characterized in that: The following steps are involved: (1) The surveillance camera captures the pedestrian video and uploads it to the cloud server, which tracks the pedestrian and crops the image; (2) Use the Transformer network to extract pedestrian image features; (3) The fusion clustering module performs fusion clustering on the extracted image features; (4) Use the multi-level contrastive learning module to obtain the relationship between instances; specifically, create a memory library to store cluster features and instance features, and use the instance-level contrast loss HIL based on difficult sample mining and the cluster-level contrast loss MUL based on the memory update strategy for training; the loss function formula is as follows: ; in, represents instance-level contrast loss HIL, It represents the cluster-level contrast loss MUL, and the parameter is a balancing factor between 0 and 1; The definition of instance-level contrast loss HIL based on difficult sample mining is as follows: ; Among them, q is the query instance feature, P represents the number of sample pairs, is the temperature hyperparameter, is the instance feature with the smallest cosine similarity ranking within the same pseudo-label, is the difficult negative instance feature, corresponding to the i-th cluster, and its cosine similarity ranks highest; ; ; in, represents the kth positive sample in the cluster to which q belongs, represents the kth sample in the i-th cluster, q is the query instance feature, and k represents all integers ranging from 1 to K; The definition of cluster-level contrast loss MUL based on memory update strategy is as follows: ; Among them, q is the query instance feature, is the proxy feature of cluster i; To query the proxy features of the cluster to which instance q belongs, is the temperature hyperparameter.
2. According to claim 1, the unsupervised person re-identification method based on contrastive learning of Transformer and fusion clustering is characterized in that: Step (1) is as follows: use the Faster RCNN algorithm to detect pedestrians, draw pedestrian detection frames, and uniformly crop pedestrian images into 256×256 pixel size to form a gallery set.
3. The unsupervised person re-identification method based on contrastive learning of Transformer and fusion clustering according to claim 1, characterized in that: Step (2) is as follows: First, the input image is processed by the convolution layer of batch normalization IBN to generate a feature map ; Where C represents the number of channels of the image, H represents the height of the image, and W represents the width of the image; then the image features are divided into P non-overlapping blocks, and each block is projected into a D-dimensional feature as an embedding tag; and an additional learnable class token is added to the input sequence and used as the input of the Transformer network; finally, it is sent to a network containing L Transformer layers, each of which consists of a multi-head attention MSA and a multi-layer perception MLP module; the final output of the Transformer network is recorded as .
4. The unsupervised person re-identification method based on contrastive learning of Transformer and fusion clustering according to claim 1, characterized in that: Step (3) is as follows: using the DBSCAN clustering algorithm to generate pseudo labels for model training; in the clustering stage, using different hyperparameters to run the DBSCAN clustering algorithm, obtaining multiple clustering results, and fusing the multiple clustering results; Assign the same pseudo label to pedestrian images belonging to the same cluster; Finally, a new labeled dataset is obtained, which is represented as ;in, The label representing the cluster, is the number of instances, Q is the number of clusters; where the hyperparameter It is 0.45, 0.5, 0.55, and 0.6.
Citation Information
Patent Citations
Unsupervised pedestrian re-identification method based on camera perception graph learning
CN115457596A
Unsupervised pedestrian re-identification method based on comparative learning
CN116524534A
