Code for my master thesis.
Download data for one or all of supported datasets: UTD-MAD and MMAct.
Create the following directory structure for ease of use and clone the project to <project directory>
:
You may also run ./<project directory>/tools/create_directory_structure.py
with ROOT as working directory
to create the remaining directories.
ROOT
|
└───<project directory>
| | ...
│ │ README.md
│ │ requirements.txt
│
└───unprocessed_data
| |
│ └───MMAct
│ | └───acc_phone_clip // include 'invalid_files.txt' from MMAct_sensor_invalid_files.tar.gz
│ | └───acc_watch_clip // include 'invalid_files.txt' from MMAct_sensor_invalid_files.tar.gz
│ | └───gyro_clip // include 'invalid_files.txt' from MMAct_sensor_invalid_files.tar.gz
│ | └───OpenPose
| | | └───COCO // Generate skeletons or paste content of MMACT_OPENPOSE_COCO.tar.gz
| | |
│ | └───orientation_clip // include 'invalid_files.txt' from MMAct_sensor_invalid_files.tar.gz
│ | └───RGB
| |
│ └───UTD-MHAD
│ | └───Depth
│ | └───Inertial
│ | └───OpenPose
| | | └───BODY_25 // Generate skeletons or paste content of UTD-MHAD_OPENPOSE_BODY_25.tar.gz
| | |
│ | └───RGB
│ | └───Skeleton
│
└───preprocessed_data // Preprocessed data will be placed here
│ └───MMAct
│ └───UTD-MHAD
|
└───models // Trained models and statistics will be placed here
│ └───mmargcn
| | └───MMAct
│ | └───UTD-MHAD
Include 'invalid_files.txt' for MMAct and OpenPose skeletons for both datasets (BODY_25 for UTD-MHAD and COCO for MMAct).
Some files can be downloaded here.
Skeletons can be generated using tools in <project directory>/tools/openpose/gen_openpose_skeletons.py
./tools/openpose/gen_openpose_skeletons.py
-d <dataset>
--openpose_binary_path=<path_to_openpose_binaries>
--openpose_python_pyth=<path_to_openpose_python_files>
with <dataset>
being either utd_mhad or mmact.
Each skeleton joint has 3 values: x, y and accuracy. Remove accuracy.
Example for MMAct: A single generated skeleton sequence has shape (sequence_length, num_joints, (x, y, accuracy) [=3], num_bodies [=2]) -> Reshape to (sequence_length, num_joints, (x, y) [=2], num_bodies [=2])
.
MMAct contains actions performed by more than a single person. If action is performed by only a single person then (:, :, :, 0) == (:, :, :, 1)
is true. For these cases the second skeleton (:, :, :, 1)
can be filled with 0
.
Create a new python environment (Code tested for Python 3.8.5 and CUDA 10.2)
Install requirements: pip install -r requirements.txt
Important :information_source:
- Working directory should always be
<project directory>
(where this file is located).- Running in PyCharm: Mark directory 'torch_src' as Sources Root
- Running in command line: Add
to PYTHONPATH ( export PYTHONPATH=`pwd`
)
Preprocess dataset:
./datasets/<dataset>/preprocess_data.py
--in_path <path_to_unprocessed_data>
--out_path <path_to_store_processed_data>
-m <preprocessing mode>
-t <target>
--split=<split>
in_path
and out_path
can be omitted if the above directory structure was created. m
is a comma separated list of the following modes (as seen in <project directory>/datasets/<dataset>/config.py
):input_data
in any configuration file under <project directory>/config/**.yaml
which modes are required for a specific training configuration.t
specifies the target modality and should only be used with at least two modes.split
is only usable with MMAct and must not be used for UTD-MHAD.
Possible values are cross_subject and cross_view.Create (or use existing) training/evaluation configuration under ./config/<dataset>/
.
Run ./torch_src/main.py -f ./config/<dataset>/**.yaml
using any configuration.
Manipulation hyperparameters using command line is also possible. View options by running ./torch_src/main.py --help
.
By default, the session type is training which trains the network and evaluates metrics for each epoch.
Alternatively, session type can be set to evaluation to load weights of a
training session and quickly recompute metrics (validation accuracy, confusion matrix, etc.) for those weights.
Example: Given training session with weights in /models/mmargcn/UTD-MHAD/training_2020_12_12-15_56_44_agcn/
for config /<project directory>/config/utd-mhad/skeleton/agcn.yaml
, to set the session type, run:
./torch_src/main.py
-f config/utd-mhad/skeleton/agcn.yaml
--session_type=evaluation
--eval_session_id=training_2020_12_12-15_56_44_agcn
./util/preprocessing/
and ./datasets/<dataset>/
.GCN: Kipf, T., & Welling, M. (2017). Semi-Supervised Classification with Graph Convolutional Networks. In International Conference on Learning Representations (ICLR). https://github.com/tkipf/gcn
ST-GCN: Spatial Temporal Graph Convolutional Networks for Skeleton-Based Action Recognition, Sijie Yan, Yuanjun Xiong and Dahua Lin, AAAI 2018. https://github.com/yysijie/st-gcn
AGCN: Lei Shi, Yifan Zhang, Jian Cheng, & Hanqing Lu (2019). Two-Stream Adaptive Graph Convolutional Networks for Skeleton-Based Action Recognition. In CVPR. https://github.com/lshiwjx/2s-AGCN
MSG3D: Liu, Z., Zhang, H., Chen, Z., Wang, Z., & Ouyang, W. (2020). Disentangling and Unifying Graph Convolutions for Skeleton-Based Action Recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (pp. 143–152). https://github.com/kenziyuliu/ms-g3d
Kensho Hara, Hirokatsu Kataoka, & Yutaka Satoh (2018). Can Spatiotemporal 3D CNNs Retrace the History of 2D CNNs and ImageNet?. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR) (pp. 6546–6555). https://github.com/kenshohara/3D-ResNets-PyTorch