Home

Awesome

Python >=3.5 Tensorflow >=1.14.0 Pytorch >=1.1.0 Faiss-gpu >= 1.6.3

SimMC: Simple Masked Contrastive Learning of Skeleton Representations for Unsupervised Person Re-Identification

By Haocong Rao and Chunyan Miao. In IJCAI 2022 (Paper, Appendices).

Introduction

This is the official implementation of SimMC presented by "SimMC: Simple Masked Contrastive Learning of Skeleton Representations for Unsupervised Person Re-Identification". The codes are used to reproduce experimental results of the proposed SimMC framework in the paper.

image Abstract: Recent advances in skeleton-based person re-identification (re-ID) obtain impressive performance via either hand-crafted skeleton descriptors or skeleton representation learning with deep learning paradigms. However, they typically require skeletal pre-modeling and label information for training, which leads to limited applicability of these methods. In this paper, we focus on unsupervised skeleton-based person re-ID, and present a generic Simple Masked Contrastive learning (SimMC) framework to learn effective representations from unlabeled 3D skeletons for person re-ID. Specifically, to fully exploit skeleton features within each skeleton sequence, we first devise a masked prototype contrastive learning (MPC) scheme to cluster the most typical skeleton features (skeleton prototypes) from different subsequences randomly masked from raw sequences, and contrast the inherent similarity between skeleton features and different prototypes to learn discriminative skeleton representations without using any label. Then, considering that different subsequences within the same sequence usually enjoy strong correlations due to the nature of motion continuity, we propose the masked intra-sequence contrastive learning (MIC) to capture intra-sequence pattern consistency between subsequences, so as to encourage learning more effective skeleton representations for person re-ID. Extensive experiments validate that the proposed SimMC outperforms most state-of-the-art skeleton-based methods. We further show its scalability and efficiency in enhancing the performance of existing models.

Environment

Here we provide a configuration file to install the extra requirements (if needed):

conda install --file requirements.txt

Note: This file will not install tensorflow/tensorflow-gpu, faiss-gpu, pytroch/torch, please install them according to the cuda version of your graphic cards: Tensorflow, Pytorch. Take cuda 9.0 for example:

conda install faiss-gpu cuda90 -c pytorch
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=9.0 -c pytorch
conda install tensorflow-gpu==1.14
conda install scikit-learn

Datasets and Models

We provide three already pre-processed datasets (IAS-Lab, BIWI, KGBD) with various sequence lengths (f=4/6/8/10/12) here (pwd: 7je2) and the pre-trained models here (pwd: 12o7). Since we report the average performance of our approach on all datasets, here the provided models may produce better results than the paper. <br/>

Please download the pre-processed datasets and model files while unzipping them to Datasets/ and ReID_Models/ folders in the current directory. <br/>

Note: The access to the Vislab Multi-view KS20 dataset and large-scale RGB-based gait dataset CASIA-B are available upon request. If you have signed the license agreement and been granted the right to use them, please email us with the signed agreement and we will share the complete pre-processed KS20 and CASIA-B data. The original datasets can be downloaded here: IAS-Lab, BIWI, KGBD, KS20, CASIA-B. We also provide the Preprocess.py for directly transforming original datasets to the formated training and testing data. <br/>

Dataset Pre-Processing

To (1) extract 3D skeleton sequences of length f=6 from original datasets and (2) process them in a unified format (.npy) for the model inputs, please simply run the following command:

python Preprocess.py 6

Note: If you hope to preprocess manually (or you can get the already preprocessed data (pwd: 7je2)), please frist download and unzip the original datasets to the current directory with following folder structure:

[Current Directory]
├─ BIWI
│    ├─ Testing
│    │    ├─ Still
│    │    └─ Walking
│    └─ Training
├─ IAS
│    ├─ TestingA
│    ├─ TestingB
│    └─ Training
├─ KGBD
│    └─ kinect gait raw dataset
└─ KS20
     ├─ frontal
     ├─ left_diagonal
     ├─ left_lateral
     ├─ right_diagonal
     └─ right_lateral

After dataset preprocessing, the auto-generated folder structure of datasets is as follows:

Datasets
├─ BIWI
│    └─ 6
│      ├─ test_npy_data
│      │    ├─ Still
│      │    └─ Walking
│      └─ train_npy_data
├─ IAS
│    └─ 6
│      ├─ test_npy_data
│      │    ├─ A
│      │    └─ B
│      └─ train_npy_data
├─ KGBD
│    └─ 6
│      ├─ test_npy_data
│      │    ├─ gallery
│      │    └─ probe
│      └─ train_npy_data
└─ KS20
    └─ 6
      ├─ test_npy_data
      │    ├─ gallery
      │    └─ probe
      └─ train_npy_data

Note: KS20 data need first transforming ".mat" to ".txt". If you are interested in the complete preprocessing of KS20 and CASIA-B, please contact us and we will share. We recommend to directly download the preprocessed data here (pwd: 7je2).

Model Usage

To (1) train the unsupervised SimMC to obtain skeleton representations and (2) validate their effectiveness on the person re-ID task on a specific dataset (probe), please simply run the following command:

python SimMC.py --dataset KS20 --probe probe

# Default options: --dataset KS20 --probe probe --length 6  --gpu 0
# --dataset [IAS, KS20, BIWI, KGBD]
# --probe ['probe' (the only probe for KS20 or KGBD), 'A' (for IAS-A probe), 'B' (for IAS-B probe), 'Walking' (for BIWI-Walking probe), 'Still' (for BIWI-Still probe)] 
# --length [4, 6, 8, 10, 12] 
# --(mask_x, lambda, t, H, lr, eps, min_samples, etc.) with default settings for each dataset
# --mode [Train (for training), Eval (for testing)]
# --gpu [0, 1, ...]

Please see SimMC.py for more details.

To print evaluation results (Top-1, Top-5, Top-10 Accuracy, mAP) of the best model saved in default directory (ReID_Models/(Dataset)/(Probe)), run:

python SimMC.py --dataset KS20 --probe probe --mode Eval

SimMC for Unsupervised Feature Fine-Tuning

Download Pre-trained Skeleton Representations

We provide skeleton representations (f=6) extrated from pre-trained state-of-the-art models: SGELA (pwd: 8hx8), MG-SCR (pwd: ox49), and SM-SGE (pwd: hrwx). Please download and unzip the files to the current directory.

Usage

To exploit the SimMC framework to fine-tune above skeleton representations pre-trained by the source models (SGELA, MG-SCR, SM-SGE) for the person re-ID task, please simply run the following command:

python SimMC-UF.py --dataset KS20 --probe probe --source SM-SGE

# Default options: --dataset KS20 --probe probe --gpu 0
# --source [SGELA, MG-SCR, SM-SGE]
# --dataset [IAS, KS20, BIWI, KGBD]
# --probe ['probe' (the only probe for KS20 or KGBD), 'A' (for IAS-A probe), 'B' (for IAS-B probe), 'Walking' (for BIWI-Walking probe), 'Still' (for BIWI-Still probe)]  
# --(mask_x, lambda, t, H, lr, eps, min_samples, etc.) with default settings for each dataset
# --mode [Train (for training), Eval (for testing)]
# --gpu [0, 1, ...]

Please see SimMC-UF.py for more details.

Application to Model-Estimated Skeleton Data

Estimate 3D Skeletons from RGB-Based Scenes

To apply our SimMC to person re-ID under the large-scale RGB scenes (CASIA B), we exploit pose estimation methods to extract 3D skeletons from RGB videos of CASIA B as follows:

We provide already pre-processed skeleton data of CASIA B for single-condition (Nm-Nm, Cl-Cl, Bg-Bg) and cross-condition evaluation (Cl-Nm, Bg-Nm) (f=40/50/60) here (pwd: 07id). Please download the pre-processed datasets into the directory Datasets/. <br/>

Usage

To (1) train the SimMC to obtain skeleton representations and (2) validate their effectiveness on the person re-ID task on CASIA B under single-condition and cross-condition settings, please simply run the following command:

python SimMC.py --dataset CASIA_B --probe_type nm.nm --length 40

# --length [40, 50, 60] 
# --probe_type ['nm.nm' (for 'Nm' probe and 'Nm' gallery), 'cl.cl', 'bg.bg', 'cl.nm' (for 'Cl' probe and 'Nm' gallery), 'bg.nm']  
# --(mask_x, lambda, t, H, lr, eps, min_samples, etc.) with default settings
# --gpu [0, 1, ...]

Please see SimMC.py for more details.

Results

KS20KGBDIAS-A
Methodstop-1top-5top-10mAPtop-1top-5top-10mAPtop-1top-5top-10mAP
D-13 Descriptors39.471.781.718.917.034.444.21.940.058.767.624.5
D-16 Descriptors51.777.186.924.031.250.959.84.042.762.970.725.2
PoseGait49.480.990.223.550.667.072.613.928.455.769.217.5
SGELA + DF49.767.077.122.243.758.765.07.118.032.146.213.5
MG-SCR46.375.484.010.444.058.764.66.936.459.669.514.1
SM-SGE + DF49.878.185.211.743.258.664.67.538.563.273.915.0
AGE43.270.180.08.92.95.67.50.931.154.867.413.4
SGELA45.065.075.121.238.153.560.04.516.730.244.013.2
SM-SGE45.971.981.29.538.254.260.74.434.060.571.613.6
SimMC (Ours)66.480.787.022.354.966.270.611.744.865.372.918.7
SGELA + SimMC47.369.779.320.151.762.767.915.116.833.348.712.0
MG-SCR + SimMC71.183.689.122.747.459.364.911.047.269.077.322.4
SM-SGE + SimMC67.282.288.523.047.159.264.910.851.369.975.627.3
IAS-BBIWI-WBIWI-S
Methodstop-1top-5top-10mAPtop-1top-5top-10mAPtop-1top-5top-10mAP
D-13 Descriptors43.768.676.723.714.220.623.717.228.353.165.913.1
D-16 Descriptors44.569.180.224.517.025.329.618.832.655.768.316.7
PoseGait28.951.662.920.88.823.031.211.114.040.756.79.9
SGELA + DF23.642.951.914.813.915.316.722.929.265.273.823.5
MG-SCR32.456.569.412.910.820.329.411.920.146.964.17.6
SM-SGE + DF44.368.277.514.916.731.040.218.734.860.671.512.8
AGE31.152.364.212.811.721.427.312.625.143.161.68.9
SGELA22.240.850.214.011.714.014.719.025.851.864.415.1
SM-SGE38.964.175.813.313.225.833.515.231.356.369.110.1
SimMC (Ours)46.368.177.022.924.536.744.519.941.766.676.812.3
SGELA + SimMC21.239.148.814.018.423.125.028.751.871.374.443.3
MG-SCR + SimMC52.472.078.829.125.137.546.420.328.351.664.810.9
SM-SGE + SimMC55.372.680.334.125.939.245.222.442.664.876.215.4

Model Size & Computational Complexity

Methods# ParamsGFLOPs
D-13 Descriptors
D-16 Descriptors
PoseGait8.93M121.60
SGELA + DF9.09M7.48
MG-SCR0.35M6.60
SM-SGE + DF6.25M23.92
AGE7.15M37.37
SGELA8.47M7.47
SM-SGE5.58M22.61
SimMC (Ours)0.15M0.99

Citation

If you find our work useful for your research, please cite our paper

@inproceedings{rao2022simmc,
  title     = {SimMC: Simple Masked Contrastive Learning of Skeleton Representations for Unsupervised Person Re-Identification},
  author    = {Rao, Haocong and Miao, Chunyan},
  booktitle = {Proceedings of the Thirty-First International Joint Conference on
               Artificial Intelligence, {IJCAI-22}},
  pages     = {1290--1297},
  year      = {2022},
  month     = {7},
  note      = {Main Track},
  doi       = {10.24963/ijcai.2022/180},
  url       = {https://doi.org/10.24963/ijcai.2022/180},
}

More awesome skeleton-based models are collected in our Awesome-Skeleton-Based-Models.

License

SimMC is released under the MIT License. Our models and codes must only be used for the purpose of research.