Skip to content

Commit 9c242ea

Browse files
committed
demos/py/human_pose_estimation/open_pose: don't rely on output_ops order in ng Function
The order for model converted with latest OpenVINO has changed
1 parent 99e09d7 commit 9c242ea

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

demos/common/python/models/open_pose.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,21 @@ def __init__(self, ie, model_path, target_size, aspect_ratio, prob_threshold, si
3636

3737
function = ng.function_from_cnn(self.net)
3838
paf = function.get_output_op(0)
39+
paf_shape = paf.outputs()[0].get_shape()
40+
heatmap = function.get_output_op(1)
41+
heatmap_shape = heatmap.outputs()[0].get_shape()
42+
if len(paf_shape) != 4 and len(heatmap_shape) != 4:
43+
raise RuntimeError('OpenPose outputs must be 4-dimensional')
44+
if paf_shape[2] != heatmap_shape[2] and paf_shape[3] != heatmap_shape[3]:
45+
raise RuntimeError('Last two dimensions of OpenPose outputs must match')
46+
if paf_shape[1] * 2 == heatmap_shape[1]:
47+
paf, heatmap = heatmap, paf
48+
elif paf_shape[1] != heatmap_shape[1] * 2:
49+
raise RuntimeError('Size of second dimension of OpenPose of one output must be two times larger then size '
50+
'of second dimension of another output')
51+
3952
paf = paf.inputs()[0].get_source_output().get_node()
4053
paf.set_friendly_name(self.pafs_blob_name)
41-
heatmap = function.get_output_op(1)
4254
heatmap = heatmap.inputs()[0].get_source_output().get_node()
4355
heatmap.set_friendly_name(self.heatmaps_blob_name)
4456

0 commit comments

Comments
 (0)