From ab3f990fd79bcbe9b3f6b551c582295b3ecd556b Mon Sep 17 00:00:00 2001 From: Naveen-Dodda <44787761+Naveen-Dodda@users.noreply.github.com> Date: Fri, 23 Jul 2021 11:06:47 -0700 Subject: [PATCH] Updating Pose_engine.py: heatmap parsing failure Latest bodypix.py demo breaks to run due to indexing issues while parsing heatmaps in pose_engine.py.Adding changes to indexes in _parse_heatmap from outputs --- pose_engine.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pose_engine.py b/pose_engine.py index 38173b8..59a2ab0 100644 --- a/pose_engine.py +++ b/pose_engine.py @@ -158,13 +158,13 @@ def __init__(self, model_path, mirror=False): def calcStride(h,w,L): return int((2*h*w)/(math.sqrt(h**2 + 4*h*L*w - 2*h*w + w**2) - h - w)) - details = self._interpreter.get_output_details()[4] + details = self._interpreter.get_output_details()[5] self.heatmap_zero_point = details['quantization_parameters']['zero_points'][0] self.heatmap_scale = details['quantization_parameters']['scales'][0] heatmap_size = self._interpreter.tensor(details['index'])().nbytes self.stride = calcStride(self.image_height, self.image_width, heatmap_size) self.heatmap_size = (self.image_width // self.stride + 1, self.image_height // self.stride + 1) - details = self._interpreter.get_output_details()[5] + details = self._interpreter.get_output_details()[6] self.parts_zero_point = details['quantization_parameters']['zero_points'][0] self.parts_scale = details['quantization_parameters']['scales'][0] @@ -235,9 +235,9 @@ def softmax(self, y, axis): def _parse_heatmaps(self, outputs): # Heatmaps are really float32. - heatmap = (outputs[4].astype(np.float32) - self.heatmap_zero_point) * self.heatmap_scale + heatmap = (outputs[5].astype(np.float32) - self.heatmap_zero_point) * self.heatmap_scale heatmap = np.reshape(heatmap, [self.heatmap_size[1], self.heatmap_size[0]]) - part_heatmap = (outputs[5].astype(np.float32) - self.parts_zero_point) * self.parts_scale + part_heatmap = (outputs[6].astype(np.float32) - self.parts_zero_point) * self.parts_scale part_heatmap = np.reshape(part_heatmap, [self.heatmap_size[1], self.heatmap_size[0], -1]) part_heatmap = self.softmax(part_heatmap, axis=2) return heatmap, part_heatmap