Realtime_Multi-Person_Pose_Estimation有许多版本,包括keras、tensorflow、pytorch等,几乎涵盖了所有深度学习框架,在这里由于进行性能分析,想用到keras中model.summary()的函数,所以采用了keras版本。
安装过程根据官方安装过程,甚至可以参考原版代码的安装流程,具体自行搜索。
在配置过程中,由于国内网络原因,许多模型无法流畅下载,提供两个caffemodel以及转换成keras格式的model.h5
相应文件格式如下:
/keras_Realtime_Multi-Person_Pose_Estimation/model/caffe/_trained_COCO :pose_iter_440000.caffemodel
/keras_Realtime_Multi-Person_Pose_Estimation/model/caffe/_trained_MPI :pose_iter_146000.caffemodel
/keras_Realtime_Multi-Person_Pose_Estimation/model/keras :model.h5
链接:https://pan.baidu.com/s/1nINVrBmubnqd1ye332YYrA
提取码:kfs0
由于主要想看到模型的每一层操作以及相应操作数,采用model.summary()进行,配置完成后,在demo.ipynb中配置代码,定义model后添加,model.summary()
weights_path = "model/keras/model.h5" # orginal weights converted from caffe
#weights_path = "training/weights.best.h5" # weights tarined from scratch
input_shape = (None,None,3)
img_input = Input(shape=input_shape)
stages = 6
np_branch1 = 38
np_branch2 = 19
img_normalized = Lambda(lambda x: x / 256 - 0.5)(img_input) # [-0.5, 0.5]
# VGG
stage0_out = vgg_block(img_normalized)
# stage 1
stage1_branch1_out = stage1_block(stage0_out, np_branch1, 1)
stage1_branch2_out = stage1_block(stage0_out, np_branch2, 2)
x = Concatenate()([stage1_branch1_out, stage1_branch2_out, stage0_out])
# stage t >= 2
for sn in range(2, stages + 1):
stageT_branch1_out = stageT_block(x, np_branch1, sn, 1)
stageT_branch2_out = stageT_block(x, np_branch2, sn, 2)
if (sn < stages):
x = Concatenate()([stageT_branch1_out, stageT_branch2_out, stage0_out])
model = Model(img_input, [stageT_branch1_out, stageT_branch2_out])
model.load_weights(weights_path)
model.summary()
运行后即可输出相应结果。