{"id":19352017,"url":"https://github.com/lukashedegaard/continual-skeletons","last_synced_at":"2025-07-14T19:43:28.652Z","repository":{"id":37991457,"uuid":"355151403","full_name":"LukasHedegaard/continual-skeletons","owner":"LukasHedegaard","description":"Official codebase for \"Online Skeleton-based Action Recognition with Continual Spatio-Temporal Graph Convolutional Networks\"","archived":false,"fork":false,"pushed_at":"2023-04-17T09:59:14.000Z","size":1775,"stargazers_count":26,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T09:51:14.882Z","etag":null,"topics":["continual-inference","convolutional-neural-networks","deep-learning","graph-neural-networks","machine-learning","online-inference","skeleton-based-action-recognition"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LukasHedegaard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-06T10:41:41.000Z","updated_at":"2025-02-25T08:08:01.000Z","dependencies_parsed_at":"2024-11-10T04:37:58.769Z","dependency_job_id":"0d2f9311-1d41-463d-8830-6ea39ed8aceb","html_url":"https://github.com/LukasHedegaard/continual-skeletons","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasHedegaard%2Fcontinual-skeletons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasHedegaard%2Fcontinual-skeletons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasHedegaard%2Fcontinual-skeletons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasHedegaard%2Fcontinual-skeletons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukasHedegaard","download_url":"https://codeload.github.com/LukasHedegaard/continual-skeletons/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250391153,"owners_count":21422849,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["continual-inference","convolutional-neural-networks","deep-learning","graph-neural-networks","machine-learning","online-inference","skeleton-based-action-recognition"],"created_at":"2024-11-10T04:37:53.436Z","updated_at":"2025-04-23T07:31:11.064Z","avatar_url":"https://github.com/LukasHedegaard.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Continual Spatio-Temporal Graph Convolutional Networks\n\n[![Paper](http://img.shields.io/badge/paper-arxiv.2203.11009-B31B1B.svg)](https://arxiv.org/abs/2203.11009)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Framework](https://img.shields.io/badge/Built_to-Ride-643DD9.svg)](https://github.com/LukasHedegaard/ride)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\u003c!-- [![codecov](https://codecov.io/gh/LukasHedegaard/continual-skeletons/branch/main/graph/badge.svg?token=GLY73KLV58)](https://codecov.io/gh/LukasHedegaard/continual-skeletons) --\u003e\n\u003c!-- [![Conference](http://img.shields.io/badge/AnyConference-year-4b44ce.svg)](https://papers.nips.cc/book/advances-in-neural-information-processing-systems-31-2018) --\u003e\n\nOfficial codebase for [\"Continual Spatio-Temporal Graph Convolutional Networks\"](https://arxiv.org/abs/2203.11009) (Pattern Recognition, 2023), including:\n\n- Models: \n[_Co_ ST-GCN](models/cost_gcn/cost_gcn.py),\n[_Co_ AGCN](models/coa_gcn/coa_gcn.py),\n[_Co_ S-TR](models/cos_tr/cos_tr.py), and more ... (see _Models_ section for full overview).\n\n\n- Datasets: \nNTU RGB+D 60,\nNTU RGB+D 120, and\nKinetics Skeleton 400.\n\n\n## Abstract\nGraph-based reasoning over skeleton data has emerged as a promising approach for human action recognition. However, the application of prior graph-based methods, which predominantly employ whole temporal sequences as their input, to the setting of online inference entails considerable computational redundancy. In this paper, we tackle this issue by reformulating the Spatio-Temporal Graph Convolutional Neural Network as a Continual Inference Network, which can perform step-by-step predictions in time without repeat frame processing. To evaluate our method, we create a continual version of ST-GCN, CoST-GCN, alongside two derived methods with different self-attention mechanisms, CoAGCN and CoS-TR. We investigate weight transfer strategies and architectural modifications for inference acceleration, and perform experiments on the NTU RGB+D 60, NTU RGB+D 120, and Kinetics Skeleton 400 datasets. Retaining similar predictive accuracy, we observe up to 109x reduction in time complexity, on-hardware accelerations of 26x, and reductions in maximum allocated memory of 52% during online inference.\n\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"figures/cost-gcn-block.svg\"\u003e\n\u003cbr\u003e\nFig. 1: Continual Spatio-temporal Graph Convolution Blocks consist of an in-time Graph Convolution followed by an across-time Continual Convolution (here a kernel size of three is depicted). The residual connection is delayed to ensure temporal alignment with the continual temporal convolution that is weight-compatible with non-continual networks.\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"figures/xsub-acc-vs-flops-log.svg\"\u003e\n\u003cbr\u003e\nFig. 2: Accuracy/complexity trade-off on NTU RGB+D 60 X-Sub for ⬥ Continual and ■ prior methods during online inference.\nNumbers denote streams for each method.\n*Architecture modification with stride one and no padding.\n\u003c/div\u003e\n\n## Setup\n### Installation\n- Clone this repository and enter it: \n    ```bash\n    git clone https://github.com/LukasHedegaard/continual-skeletons.git\n    cd continual-skeletons\n    ```\n- Optionally create and activate conda environment:\n    ```bash\n    conda create --name continual-skeletons python=3.8\n    conda activate continual-skeletons\n    ```\n- Install as editable module\n    ```bash\n    pip install -e .[dev]\n    ```\n\n\n## Repository structure\nThe repository is s\n```python\nroot\n|- datasets/     # Dataset loaders\n|- models/       # Individual models and shared base-code\n    |- ...\n    |- st_gcn/       # Baseline model\n    |- cost_gcn/     # Continual version of model\n    |- st_gcn_mod/   # Modified baseline with stride one and no padding\n    |- cost_gcn_mod/ # Continual version of modified baseline model\n        |- cost_gcn_mod.py  # Python entry-point\n        |- scripts/         # Scripts used to achieve results from paper. Please run from root.\n            |- evaluate_ntu60.py\n            |- evaluate_ntu120.py\n            |- evaluate_kinetics.py\n            |- ...\n|- tests/     # Unit tests for custom modules\n|- weights/   # Place pretrained weights here\n|- preds/     # Place extracted predictions here to perform multi-stream eval\n|- Makefile   # Commands for testing, linting, cleaning.\n|- .env       # Modify path to your dataset here, i.e. DATASETS_PATH=/my/path\n```\n\n## Dataset preparation\nDownload the skeleton data of NTU-RGBD-60 and NTU-RGBD-120 from [here](https://rose1.ntu.edu.sg/dataset/actionRecognition/) and put them in [nturgbd_raw](datasets/data_preparation/nturgbd_raw) directory.\nName the folder of the downloaded skeletons folder for NTU-RGBD-60 and NTU-RGBD-120 as `nturgb+d_skeletons60`, `nturgb+d_skeletons120`, respectively. \nThe skeleton data for [Kinetics](https://arxiv.org/pdf/1705.06950.pdf) dataset is extracted using [Openpose](https://github.com/CMU-Perceptual-Computing-Lab/openpose) toolbox by [ST-GCN](https://github.com/yysijie/st-gcn) authors. \nThe extracted skeleton data called Kinetics-skeleton (7.5GB) can be directly downloaded from [GoogleDrive](https://drive.google.com/drive/folders/1SPQ6FmFsjGg3f59uCWfdUWI-5HJM_YhZ), and it should be placed in [kinetics_raw](datasets/data_preparation/kinetics_raw) directory. \n\nBefore training and testing the models, the datasets should be preprocessed. The downloaded data should be placed in the following directories:\n\n```python\nroot\n|- datasets/     \n|- data_preparation/       \n    |- nturgbd_raw\\        # Raw NTU-RGBD skeleton data\n        |- nturgb+d_skeletons60\\   # Skeleton data for NTU-RGBD-60\n        |- nturgb+d_skeletons120\\   # Skeleton data for NTU-RGBD-120\n        |- ...\n        |- ntu60_samples_with_missing_skeletons.txt   # Sample IDs with missing skeletons in NTU-RGBD-60\n        |- ntu120_samples_with_missing_skeletons.txt  # Sample IDs with missing skeletons in NTU-RGBD-120\n  \n   |- kinetics_raw\\         # Raw Kinetics data\n        |- kinetics_train\\\n        |- ...\n        |- kinetics_val\\\n        |- ...\n        |- kinetics_train_label.json\n        |- kinetics_val_label.json\n\n```\nFor generating the preprocedded data you need to run the following commands: \n\n```bash\n# NTU-RGBD-60\npython datasets/data_preparation/ntu60_prep.py \n# NTU-RGBD-120\npython datasets/data_preparation/ntu120_prep.py \n# Kinetics\npython datasets/data_preparation/kinetics400_prep.py \n```\n\nFor generating bone and motion data for each of the datasets run the following commands:\n```bash\n# Bone generation\npython datasets/data_preparation/bone_data_prep.py \n# Motion generation\npython datasets/data_preparation/motion_data_prep.py \n```\n\nThe joint and bone skeleton data can be concatenated by running the following command: \n```bash\n# joint_bone data concatenation\npython datasets/data_preparation/merge_joint_bone_data.py \n```\n\n\n## Models\nIndividual folders with relevant scripts are avilable under `/models` for the following models:\n- [ST-GCN](models/st_gcn/st_gcn.py) (baseline)\n- [ST-GCN*](models/st_gcn_mod/st_gcn_mod.py)\n- [_Co_ ST-GCN](models/cost_gcn/cost_gcn.py)\n- [_Co_ ST-GCN*](models/cost_gcn_mod/cost_gcn_mod.py)\n- [AGCN](models/a_gcn/a_gcn.py) (baseline)\n- [AGCN*](models/a_gcn_mod/a_gcn_mod.py)\n- [_Co_ AGCN](models/coa_gcn/coa_gcn.py)\n- [_Co_ AGCN*](models/coa_gcn_mod/coa_gcn_mod.py)\n- [S-TR](models/s_tr/s_tr.py) (baseline)\n- [S-TR*](models/s_tr_mod/s_tr_mod.py)\n- [_Co_ S-TR](models/cos_tr/cos_tr.py)\n- [_Co_ S-TR*](models/cos_tr_mod/cos_tr_mod.py)\n\nTo see an overview of available commands for a model, check the help, e.g.: \n```bash\npython models/cost_gcn/cost_gcn.py --help\n```\n\nThe commands used to produce the paper results are found in the associated scripts folder, e.g.:\n```bash\npython models/cost_gcn/scripts/evaluate_ntu60.py\n```\n\n### Pretrained weights\nTrained model weights are available [here](https://drive.google.com/drive/folders/1m6aV5Zv8tAytvxF6qY4m9nyqlkKv0y72?usp=sharing).\n\n\n## Experiments and results\nTo reproduce results:\n- Prepare datasets\n    - Download and preprocessing guidelines coming up\n    - Add `DATASET_PATH=/your/dataset/path` to `.env`.\n- Download [pretrained weights](https://drive.google.com/drive/folders/1m6aV5Zv8tAytvxF6qY4m9nyqlkKv0y72) and place them in `~/weights`.\n- Run evaluation script. For instance, to evaluate the CoST-GCN* model on NTU RGB+D 120 and save its predictions, the command would be:\n    ```bash\n    python models/cost_gcn/scripts/evaluate_ntu120.py\n    ```\n\n### Benchmark\n\u003cdiv align=\"center\"\u003e \u003cimg src=\"figures/table-2.png\"\u003e \u003c/div\u003e\n\n### NTU RGB+D 60\n\u003cdiv align=\"center\"\u003e \u003cimg src=\"figures/table-3.png\"\u003e \u003c/div\u003e\n\n### NTU RGB+D 120\n\u003cdiv align=\"center\"\u003e \u003cimg src=\"figures/table-4.png\"\u003e \u003c/div\u003e\n\n### Kinetics Skeletons 400\n\u003cdiv align=\"center\"\u003e \u003cimg src=\"figures/table-5.png\"\u003e \u003c/div\u003e\n\n## Citation\n\n```bibtex\n@article{hedegaard2023continual,\ntitle = {Continual spatio-temporal graph convolutional networks},\nauthor = {Lukas Hedegaard and Negar Heidari and Alexandros Iosifidis},\njournal = {Pattern Recognition},\nvolume = {140},\npages = {109528},\nyear = {2023},\nissn = {0031-3203},\ndoi = {https://doi.org/10.1016/j.patcog.2023.109528},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukashedegaard%2Fcontinual-skeletons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukashedegaard%2Fcontinual-skeletons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukashedegaard%2Fcontinual-skeletons/lists"}