PyTorch-Pose is a PyTorch implementation of the general pipeline for 2D single human pose estimation. The aim is to provide the interface of the training/inference/evaluation, and the dataloader with various data augmentation options for the most popular human pose databases (e.g., the MPII human pose, LSP and FLIC).
Some codes for data preparation and augmentation are brought from the Stacked hourglass network. Thanks to the original author.
- Multi-thread data loading
- Multi-GPU training
- Logger
- Training/testing results visualization
-
Please follow the installation instruction of PyTorch. Note that the code is developed with Python2 and has not been tested with Python3 yet.
-
Clone the repository with submodule
git clone --recursive https://github.com/bearpaw/pytorch-pose.git
-
Create a symbolic link to the
images
directory of the MPII dataset:ln -s PATH_TO_MPII_IMAGES_DIR data/mpii/images
You may download our pretrained 4-stack hourglass model for a quick start.
Run the following command in terminal to evaluate the model on MPII validation split (The train/val split is from Tompson et al. CVPR 2015).
CUDA_VISIBLE_DEVICES=0 python example/mpii.py -a hg4 --checkpoint checkpoint/mpii/hg4 --resume checkpoint/mpii/hg4/model_best.pth.tar -e -d
-a
specifies a network architecture--resume
will load the weight from a specific model-e
stands for evaluation only-d
will visualize the network output. It can be also used during training
The result will be saved as a .mat
file (preds_valid.mat
), which is a 2958x16x2
matrix, in the folder specified by --checkpoint
.
You may use the matlab script evaluation/eval_PCKh.m
to evaluate your predictions. The evaluation code is ported from Tompson et al. CVPR 2015.
The result (PCKh@0.5 score) of the 4-stack hourglass model trained using this code is reported in the following table.
Model | Head | Shoulder | Elbow | Wrist | Hip | Knee | Ankle | Mean |
---|---|---|---|---|---|---|---|---|
hg4 | 96.28 | 92.34 | 82.60 | 78.10 | 83.42 | 77.96 | 73.62 | 83.58 |
Run the following command in terminal to train a single stack of hourglass network on the MPII human pose dataset.
CUDA_VISIBLE_DEVICES=0 python example/mpii.py -a hg1 --checkpoint checkpoint/mpii/hg1 -j 4
Here,
CUDA_VISIBLE_DEVICES=0
identifies the GPU devices you want to use. For example, useCUDA_VISIBLE_DEVICES=0,1
if you want to use two GPUs with ID0
and1
.-j
specifies how many workers you want to use for data loading.--checkpoint
specifies where you want to save the models, the log and the predictions to.
Please refer to the example/mpii.py
for the supported options/arguments.
Supported dataset
- MPII human pose
- FLIC
- LSP
Supported models
Please create a pull request if you want to contribute.