This is a Keras implementation for stacked hourglass network for single human pose estimation. The stacked hourglass network was proposed by [Stacked Hourglass Networks for Human Pose Estimation] (https://arxiv.org/abs/1603.06937). The official implementation built on top of torch is released under pose-hg-train, and pytorch version wrote by berapaw in repo pytorch-pose. Most of code for image processing and evaluation come from above repos.
data
: data folder, mpiiimages
: pictures for demosrc
: source codesrc/data_gen
: data generator, augmentation and processnig codesrc/eval
: evaluation code, eval callbacksrc/net
: net definition, hourglass network implementationsrc/tools
: tool to draw accuracy curve and convert keras model to tf graph.top
: top level entry to train/eval/demo networktrained_models
: folder to restore trained models.Download pre-trained model from shared drive and put them under trained_models
BaiDu Pan: hg_s2_b1_mobile and hg_s2_b1
Google Drive: hg_s2_b1_mobile and
hg_s2_b1
Run a quick demo to predict sample image
python demo.py --gpuID 0 --model_json ../../trained_models/hg_s2_b1/net_arch.json --model_weights ../../trained_models/hg_s2_b1/weights_epoch89.h5 --conf_threshold 0.1 --input_image ../../images/sample.jpg
data/mpii/images
mpii_annotations.json
contains all of images' annotations including train and validation.Train from scratch, use python train.py --help
to check all the valid arguments.
python train.py --gpuID 0 --epochs 100 --batch_size 24 --num_stack 2 --model_path ../../trained_models/hg_s2_b1_m
Arguments:
gpuID
gpu id, epochs
number of epoch to train, batch_size
batch size of samples to train, num_stack
number of hourglass stack, model_path
path to store trained model snapshot
Note:
When mobile
set as True, SeparableConv2D()
is used instead of standard convolution, which is much smaller and faster.
Continue training from previous checkpoint
python train.py --gpuID 0 --epochs 100 --batch_size 24 --num_stack 2 --model_path ../../trained_models/hg_s2_b1_m --resume True --resume_model_json ../../trained_models/hg_s2_b1_m/net_arch.json --resume_model ../../trained_models/hg_s2_b1_m/weights_epoch15.h5 --init_epoch 16
Run evaluation on MPII validation dataset by using PCKh=0.5.
python eval.py --gpuID 1 --model_weights ../../trained_models/hg_s2_b1_mobile/weights_epoch70.h5 --model_json ../../trained_models/hg_s2_b1_mobile/net_arch.json --mat_file ../../trained_models/hg_s2_b1_mobile/preds.mat --num_stack 2
The validation score curve for hg_s2_b1
and hg_s2_b1_mobile