1

I have downloaded and am implementing a ML application using the Tensorflow Lite Posenet Model. The output of this model is a heatmap, which is a part of CNN's I am new to.

One piece of information required to process the output is the "output stride". It is used to calculate the original coordinates of the keypoints found in the original image.

keypointPositions = heatmapPositions * outputStride + offsetVectors

But the documentation doesn't specify the output stride. Is there information or a way available in tensorflow I can use to get the output stride for this (any) pre-trained model?

  • The input shape for an img is: (257,257,3)
  • The output shape is: (9,9,17) (1 [9x9] heatmap for 17 different keypoints)
import tensorflow as tf
import numpy as np
import json

model = tf.lite.Interpreter('models\posenet_mobilenet_v1_100_257x257_multi_kpt_stripped.tflite')
model.allocate_tensors()

with open('model_details.json', 'w') as outfile:
     info = dict(list(enumerate(model.get_tensor_details())))
     s = json.dumps(str(info))
     outfile.write(s)
Josh Sharkey
  • 1,008
  • 9
  • 34

1 Answers1

2

The output stride can be obtained from the following equation:

resolution = ((InputImageSize - 1) / OutputStride) + 1

Example: An input image with a width of 225 pixels and an output stride of 16 results in an output size of 15

15 = ((225 - 1) / 16) + 1

For the tflite PoseNet model (resolution is 9):

9 = ((257-1)/ x) + 1 x = 32 so the output stride is 32

Source

Josh Sharkey
  • 1,008
  • 9
  • 34
  • Can you little bit elaborate that what is the output stride in pose net , How it matters in Pose net model , How it is calculated and which number it should be ! . Kindly explain briefly ? – Hamza Apr 13 '21 at 07:30
  • Please take a look at the attached source: In it, it explains: "this parameter affects the height and width of the layers in the neural network. At a high level, it affects the accuracy and speed of the pose estimation. The lower the value of the output stride the higher the accuracy but slower the speed, the higher the value the faster the speed but lower the accuracy. The best way to see the effect of the output stride on output quality is to play with the single-pose estimation demo." – Josh Sharkey Apr 13 '21 at 20:01
  • Here is the demo: https://storage.googleapis.com/tfjs-models/demos/posenet/camera.html – Josh Sharkey Apr 13 '21 at 20:02
  • I want to know that why it is happening , what is the reason inside the PoseNET ? – Hamza Apr 14 '21 at 04:55