Tensorflow: Determine the output stride of a pretrained CNN model

被刻印的时光 ゝ 提交于 2020-02-25 04:16:17

问题


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)

回答1:


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:

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

Source



来源:https://stackoverflow.com/questions/60068651/tensorflow-determine-the-output-stride-of-a-pretrained-cnn-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!