[ICCV2021] Official code for "Channel-wise Topology Refinement Graph Convolution for Skeleton-Based Action Recognition"

Overview

CTR-GCN

This repo is the official implementation for Channel-wise Topology Refinement Graph Convolution for Skeleton-Based Action Recognition. The paper is accepted to ICCV2021.

Note: We also provide a simple and strong baseline model, which achieves 83.7% on NTU120 CSub with joint modality only, to facilitate the development of skeleton-based action recognition.

Architecture of CTR-GC

image

Prerequisites

  • Python >= 3.6

  • PyTorch >= 1.1.0

  • PyYAML, tqdm, tensorboardX

  • We provide the dependency file of our experimental environment, you can install all dependencies by creating a new anaconda virtual environment and running pip install -r requirements.txt

  • Run pip install -e torchlight

Data Preparation

Download datasets.

There are 3 datasets to download:

  • NTU RGB+D 60 Skeleton
  • NTU RGB+D 120 Skeleton
  • NW-UCLA

NTU RGB+D 60 and 120

  1. Request dataset here: http://rose1.ntu.edu.sg/Datasets/actionRecognition.asp
  2. Download the skeleton-only datasets:
    1. nturgbd_skeletons_s001_to_s017.zip (NTU RGB+D 60)
    2. nturgbd_skeletons_s018_to_s032.zip (NTU RGB+D 120)
    3. Extract above files to ./data/nturgbd_raw

NW-UCLA

  1. Download dataset from here
  2. Move all_sqe to ./data/NW-UCLA

Data Processing

Directory Structure

Put downloaded data into the following directory structure:

- data/
  - NW-UCLA/
    - all_sqe
      ... # raw data of NW-UCLA
  - ntu/
  - ntu120/
  - nturgbd_raw/
    - nturgb+d_skeletons/     # from `nturgbd_skeletons_s001_to_s017.zip`
      ...
    - nturgb+d_skeletons120/  # from `nturgbd_skeletons_s018_to_s032.zip`
      ...

Generating Data

  • Generate NTU RGB+D 60 or NTU RGB+D 120 dataset:
 cd ./data/ntu # or cd ./data/ntu120
 # Get skeleton of each performer
 python get_raw_skes_data.py
 # Remove the bad skeleton 
 python get_raw_denoised_data.py
 # Transform the skeleton to the center of the first frame
 python seq_transformation.py

Training & Testing

Training

  • Change the config file depending on what you want.
# Example: training CTRGCN on NTU RGB+D 120 cross subject with GPU 0
python main.py --config config/nturgbd120-cross-subject/default.yaml --work-dir work_dir/ntu120/csub/ctrgcn --device 0
# Example: training provided baseline on NTU RGB+D 120 cross subject
python main.py --config config/nturgbd120-cross-subject/default.yaml --model model.baseline.Model--work-dir work_dir/ntu120/csub/baseline --device 0
  • To train model on NTU RGB+D 60/120 with bone or motion modalities, setting bone or vel arguments in the config file default.yaml or in the command line.
# Example: training CTRGCN on NTU RGB+D 120 cross subject under bone modality
python main.py --config config/nturgbd120-cross-subject/default.yaml --train_feeder_args bone=True --test_feeder_args bone=True --work-dir work_dir/ntu120/csub/ctrgcn_bone --device 0
  • To train model on NW-UCLA with bone or motion modalities, you need to modify data_path in train_feeder_args and test_feeder_args to "bone" or "motion" or "bone motion", and run
python main.py --config config/ucla/default.yaml --work-dir work_dir/ucla/ctrgcn_xxx --device 0
  • To train your own model, put model file your_model.py under ./model and run:
# Example: training your own model on NTU RGB+D 120 cross subject
python main.py --config config/nturgbd120-cross-subject/default.yaml --model model.your_model.Model --work-dir work_dir/ntu120/csub/your_model --device 0

Testing

  • To test the trained models saved in <work_dir>, run the following command:
python main.py --config <work_dir>/config.yaml --work-dir <work_dir> --phase test --save-score True --weights <work_dir>/xxx.pt --device 0
  • To ensemble the results of different modalities, run
# Example: ensemble four modalities of CTRGCN on NTU RGB+D 120 cross subject
python ensemble.py --datasets ntu120/xsub --joint-dir work_dir/ntu120/csub/ctrgcn --bone-dir work_dir/ntu120/csub/ctrgcn_bone --joint-motion-dir work_dir/ntu120/csub/ctrgcn_motion --bone-motion-dir work_dir/ntu120/csub/ctrgcn_bone_motion

Pretrained Models

  • Download pretrained models for producing the final results on NTU RGB+D 60&120 cross subject [Google Drive].
  • Put files to <work_dir> and run Testing command to produce the final result.

Acknowledgements

This repo is based on 2s-AGCN. The data processing is borrowed from SGN and HCN.

Thanks to the original authors for their work!

Citation

Please cite this work if you find it useful:.

@article{chen2021channel,
  title={Channel-wise Topology Refinement Graph Convolution for Skeleton-Based Action Recognition},
  author={Chen, Yuxin and Zhang, Ziqi and Yuan, Chunfeng and Li, Bing and Deng, Ying and Hu, Weiming},
  journal={arXiv preprint arXiv:2107.12213},
  year={2021}
}

Contact

For any questions, feel free to contact: [email protected]

Comments
  • Thank you for your great work

    Thank you for your great work

    I've been reading your work and have a few questions that I'd like to ask you

    1. For the equation 7, the Q in the code, somewhat like non-local block,could you tell me the difference between the two? I mean non-local is also spatio-temporal modelling of the relationship between two joints, it feels like it's just condensing time.
    2. For the equation 8, you use three CTR-GCNs to add in a torch-list, so it looks like in the 2s-AGCN do, do I understand you correctly? This divides the code with ke cheng DeCoupling GCN`s point being made the same? norm_learn_A = torch.cat([self.norm(learn_A[0:1, ...]), self.norm(learn_A[1:2, ...]), self.norm(learn_A[2:3, ...])], 0)
    opened by ChenHongBo0420 6
  • Understanding the inward_ori_index variable in the ntu_rgb_d.py file in the Graph folder

    Understanding the inward_ori_index variable in the ntu_rgb_d.py file in the Graph folder

    Hello, thank you so much for your hard work. I am trying to understand how the inward_ori_index, the tuples of joints considered linked, were determined.

    For instance, as far as I understand these are the joint numbers (using 0-indexing): joint_names_dict = {0: "spine_base", 1:"spine_mid", 2: "neck", 3:"head", 4:"shoulder_left", 5:"elbow_left", 6: "wrist_left", 7: "hand_left", 8: "shoulder_right", 9:"elbow_right", 10:"wrist_right", 11:"hand_right", 12: "hip_left", 13:"knee_left", 14:"ankle_left", 15:"foot_left", 16:"hip_right", 17:"knee_right", 18:"ankle_right", 19: "foot_right", 20:"spine_shoulder", 21:"hand_tip_left", 22:"thumb_left", 23:"hand_tip_right", 24:"thumb_right"}

    What was the thought process between choosing the pairs

    inward_ori_index = [(1, 2), (2, 21), (3, 21), (4, 3), (5, 21), (6, 5), (7, 6),
                        (8, 7), (9, 21), (10, 9), (11, 10), (12, 11), (13, 1),
                        (14, 13), (15, 14), (16, 15), (17, 1), (18, 17), (19, 18),
                        (20, 19), (22, 23), (23, 8), (24, 25), (25, 12)]
    
    opened by JamesMcCullochDickens 2
  • how can i train it on other datasets?

    how can i train it on other datasets?

    if i want to train it on other dataset,does【 get_raw_denoised_data.py】【get_raw_skes_data.py】【seq_transformation.py】necessary? and what py documents should i need to modify? thank u very much!!

    opened by sayoko17 2
  • About NTU60_CS.npz file

    About NTU60_CS.npz file

    Hi, I'm very interested in your work. But I met a problem while running the code.

    The problem as follow: FileNotFoundError: [Errno 2] No such file or directory: 'data/ntu/NTU60_CS.npz'

    What is the NTU60_CS.npz file?

    Best regards!

    opened by Morning-YU 2
  • Is there another way to implement this api?

    Is there another way to implement this api?

    def forward(self, x, A=None, alpha=1):
        x1, x2, x3 = self.conv1(x).mean(-2), self.conv2(x).mean(-2), self.conv3(x)
        x1 = self.tanh(x1.unsqueeze(-1) - x2.unsqueeze(-2))
        x1 = self.conv4(x1) * alpha + (A.unsqueeze(0).unsqueeze(0) if A is not None else 0)  # N,C,V,V
        **x1 = torch.einsum('ncuv,nctv->nctu', x1, x3)**
    

    I want to use another Deeplearning framework to achieve this model, but I can't find the einsum api, can we use other normal api to replace it ?

    opened by universea 2
  • about implementation details

    about implementation details

    I run your code (use default.yaml),but I didn't get as good results as your article reported. Could you please provide the more details about your specific content of configuration file ? Thank you !!

    opened by jjingli 2
  • How can i reproduce the sota results

    How can i reproduce the sota results

    Hi! Thanks for sharing your excellent work. I trained the model using the given config file, but the result is not as good as in the paper. The performance on ntu60 cross-subject i got on joint stream is 89.52% which is worse than yours of 0.4%. And i also test the pre-trained weights on my data, the test results are consistent with expectations(89.9%). So i suppose the problem is not with the data. Do you have any idea why this is the case, or there are any details of the implementation I failed to pay attention to?

    opened by SLime1998 1
  • Issues on

    Issues on "lr_decay_rate"

    Thanks for sharing your work, but I found the issue on hyper-param: lr_decay_rate in the config files and main.py. I think there should be a term: lr_decay_rate in the yaml files, and this hyper-param should also be added to the parser in the main.py.

    opened by sayano-lee 1
  • Why are the training results low on xset120?

    Why are the training results low on xset120?

    I followed the instructions and retrained the model on ntu60/120, but the accuracy on xset is only 89.5%, I tried changing the seed to retrain, but the results are still similar, the results on ntu60 and xsub120 are normal, please How to solve it?

    opened by ch1998 0
  • Validating data during training

    Validating data during training

    Hello guys thank you for your great work!

    I was just wondering why you do not validate the data with a validation set during training in order to use the early stopping mechanism. Also what if the best accuracy is achieved after epoch 65?

    Thank you in advance.

    opened by joyios1 0
  • Can't get state of the art performance on NW-UCLA dataset

    Can't get state of the art performance on NW-UCLA dataset

    In the paper you have mentioned CTR-GCN to get 96.5 on NW-UCLA dataset. However when I trained and ensembled as mentioned in readme, the accuracy I got was only 95%.

    Please clarify

    opened by neel1998 4
  • train stage eval result is inconsistent with the test stage eval results

    train stage eval result is inconsistent with the test stage eval results

    Hi, PhD Chen. I met a strange problem.When I test the trained model, whether i use '--test--feeder-args bone=true' or not,its accuracy is inconsistent with the test results in the training stage, and it is much lower. the pic: image image image

    opened by zw20yz 0
  • Data Normalization

    Data Normalization

    Hi, I just have trained your model on UCLA dataset and need to pass it my videos data. I have a skeleton file with non normalized 3D joint coordinates can you provide the code to normalize them accordingly with yours? Since I have tried to applied the same normalization described for NTU dataset here "NTU RGB+D: A Large Scale Dataset for 3D Human Activity Analysis" but we are having trouble with our final results. Thank you

    opened by amcorGit 2
Owner
Yuxin Chen
PhD candidate at the Institute of Automation, Chinese Academy of Sciences.
Yuxin Chen
Official PyTorch code for Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021)

Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021) This repository is the official P

Jingyun Liang 159 Dec 30, 2022
Official PyTorch code for Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021)

Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021) This repository is the official P

Jingyun Liang 159 Dec 30, 2022
Official code of ICCV2021 paper "Residual Attention: A Simple but Effective Method for Multi-Label Recognition"

CSRA This is the official code of ICCV 2021 paper: Residual Attention: A Simple But Effective Method for Multi-Label Recoginition Demo, Train and Vali

null 163 Dec 22, 2022
Official PyTorch code for Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (MANet, ICCV2021)

Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (MANet, ICCV2021) This repository is the official PyTorc

Jingyun Liang 139 Dec 29, 2022
Official code for ICCV2021 paper "M3D-VTON: A Monocular-to-3D Virtual Try-on Network"

M3D-VTON: A Monocular-to-3D Virtual Try-On Network Official code for ICCV2021 paper "M3D-VTON: A Monocular-to-3D Virtual Try-on Network" Paper | Suppl

null 109 Dec 29, 2022
Official PyTorch Implementation of Rank & Sort Loss [ICCV2021]

Rank & Sort Loss for Object Detection and Instance Segmentation The official implementation of Rank & Sort Loss. Our implementation is based on mmdete

Kemal Oksuz 229 Dec 20, 2022
Official implementation of "A Unified Objective for Novel Class Discovery", ICCV2021 (Oral)

A Unified Objective for Novel Class Discovery This is the official repository for the paper: A Unified Objective for Novel Class Discovery Enrico Fini

Enrico Fini 118 Dec 26, 2022
This is an official implementation of the paper "Distance-aware Quantization", accepted to ICCV2021.

PyTorch implementation of DAQ This is an official implementation of the paper "Distance-aware Quantization", accepted to ICCV2021. For more informatio

CV Lab @ Yonsei University 36 Nov 4, 2022
Official Repo for ICCV2021 Paper: Learning to Regress Bodies from Images using Differentiable Semantic Rendering

[ICCV2021] Learning to Regress Bodies from Images using Differentiable Semantic Rendering Getting Started DSR has been implemented and tested on Ubunt

Sai Kumar Dwivedi 83 Nov 27, 2022
source code of “Visual Saliency Transformer” (ICCV2021)

Visual Saliency Transformer (VST) source code for our ICCV 2021 paper “Visual Saliency Transformer” by Nian Liu, Ni Zhang, Kaiyuan Wan, Junwei Han, an

null 89 Dec 21, 2022
Code and models for ICCV2021 paper "Robust Object Detection via Instance-Level Temporal Cycle Confusion".

Robust Object Detection via Instance-Level Temporal Cycle Confusion This repo contains the implementation of the ICCV 2021 paper, Robust Object Detect

Xin Wang 69 Oct 13, 2022
Code for Talk-to-Edit (ICCV2021). Paper: Talk-to-Edit: Fine-Grained Facial Editing via Dialog.

Talk-to-Edit (ICCV2021) This repository contains the implementation of the following paper: Talk-to-Edit: Fine-Grained Facial Editing via Dialog Yumin

Yuming Jiang 221 Jan 7, 2023
The source code of the ICCV2021 paper "PIRenderer: Controllable Portrait Image Generation via Semantic Neural Rendering"

The source code of the ICCV2021 paper "PIRenderer: Controllable Portrait Image Generation via Semantic Neural Rendering"

Ren Yurui 261 Jan 9, 2023
Dynamic Attentive Graph Learning for Image Restoration, ICCV2021 [PyTorch Code]

Dynamic Attentive Graph Learning for Image Restoration This repository is for GATIR introduced in the following paper: Chong Mou, Jian Zhang, Zhuoyuan

Jian Zhang 84 Dec 9, 2022
Dense Deep Unfolding Network with 3D-CNN Prior for Snapshot Compressive Imaging, ICCV2021 [PyTorch Code]

Dense Deep Unfolding Network with 3D-CNN Prior for Snapshot Compressive Imaging, ICCV2021 [PyTorch Code]

Jian Zhang 20 Oct 24, 2022
The source code of the ICCV2021 paper "PIRenderer: Controllable Portrait Image Generation via Semantic Neural Rendering"

Website | ArXiv | Get Start | Video PIRenderer The source code of the ICCV2021 paper "PIRenderer: Controllable Portrait Image Generation via Semantic

Ren Yurui 81 Sep 25, 2021
Code for ICCV2021 paper SPEC: Seeing People in the Wild with an Estimated Camera

SPEC: Seeing People in the Wild with an Estimated Camera [ICCV 2021] SPEC: Seeing People in the Wild with an Estimated Camera, Muhammed Kocabas, Chun-

Muhammed Kocabas 187 Dec 26, 2022
HiFT: Hierarchical Feature Transformer for Aerial Tracking (ICCV2021)

HiFT: Hierarchical Feature Transformer for Aerial Tracking Ziang Cao, Changhong Fu, Junjie Ye, Bowen Li, and Yiming Li Our paper is Accepted by ICCV 2

Intelligent Vision for Robotics in Complex Environment 55 Nov 23, 2022
Implementation of ICCV2021(Oral) paper - VMNet: Voxel-Mesh Network for Geodesic-aware 3D Semantic Segmentation

VMNet: Voxel-Mesh Network for Geodesic-Aware 3D Semantic Segmentation Created by Zeyu HU Introduction This work is based on our paper VMNet: Voxel-Mes

HU Zeyu 82 Dec 27, 2022