Home

Awesome

Fast_Stacked_Hourglass_Network_OpenVino

A fast stacked hourglass network for human pose estimation on OpenVino. Stacked hourglass network proposed by Stacked Hourglass Networks for Human Pose Estimation is a very good network for single-person pose estimation regarding to speed and accuracy. This repo contains a demo to show how to depoly model trained by Keras. It converts a Keras model to IR and shows how to use the generated IR to do inference. Have fun with OpenVino!

Installation

keras==2.1.5
scipy==1.2.0
tensorflow==1.12.0
opencv-python==3.4.3.18

[Keras] Convert pre-trained Keras models

Download pre-trained hourglass models

Convert keras models to tensorflow forzen pb

python3 tools/keras_to_tfpb.py --input_model_json ./models/path/to/network/json --input_model_weights
./models/path/to/network/weight/h5 --out_tfpb ./models/hg_s2_b1_tf.pb

Use OpenVino Model Optimizer to convert tf pb to IR.

~/intel/computer_vision_sdk/deployment_tools/model_optimizer/mo_tf.py -w ./models/hg_s2_b1_tf.pb --input_shape [1,256,256,3] --data_type FP32 --output_dir ./models/ --model_name hg_s2_mobile
~/intel/computer_vision_sdk/deployment_tools/model_optimizer/mo_tf.py -w ./models/hg_s2_b1_tf.pb --input_shape [1,192,128,3] --data_type FP16 --output_dir ./models/ --model_name hg_s2_tiny

[PyTorch] Convert pre-trained Onnx models

Download model trained by pytorch

Download the model_best.onnx model from below table to fit your accuracy and speed requirements. hg_s2_b1_mobile_fpd model trained by using the knowledge distillation proposed by paper Fast Human Pose Estimation. Details can be found in Fast_Human_Pose_Estimation_Pytorch.

Modelin_resfeatrues# of WeightsHeadShoulderElbowWristHipKneeAnkleMeanLink
hg_s2_b12561286.73m95.7494.5187.6881.7087.8180.8876.8386.58GoogleDrive
hg_s2_b1_mobile2561282.31m95.8093.6185.5079.6386.1377.8273.6284.69GoogleDrive
hg_s2_b1_mobile_fpd2561282.31m95.6794.0786.3179.6886.0079.6775.5185.41GoogleDrive
hg_s2_b1_tiny1921282.31m94.9592.8784.5978.1984.6877.7073.0783.88GoogleDrive

Convert onnx to IR

Use model optimizer to convert onnx to IR. FP32 for CPU while FP16 for MYRIAD

~/intel/computer_vision_sdk/deployment_tools/model_optimizer/mo.py -w ./models/model_best.onnx --data_type FP32 --output_dir ./models/ --model_name hg_s2_mobile_onnx 

Run demo

cd src
python3 stacked_hourglass.py -i ../models/sample.jpg -m ../models/hg_s2_mobile.xml -d CPU -l /path/to/cpu/extension/library
cd src
python3 stacked_hourglass.py -i ../models/sample.jpg -m ../models/hg_s2_tiny.xml -d MYRIAD
cd src
python3 stacked_hourglass_camera_async.py -i cam -m ../models/hg_s2_mobile.xml -d CPU -l /path/to/cpu/extension/library

Reference