Tensorflow:确定预训练的CNN模型的输出步幅 [英] Tensorflow: Determine the output stride of a pretrained CNN model

查看:427
本文介绍了Tensorflow:确定预训练的CNN模型的输出步幅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Tensorflow Lite Posenet模型.该模型的输出是一个热图,它是我刚接触CNN的一部分.

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

但是文档没有指定输出步幅.我可以使用tensorflow中的信息或方法来获得此(任何)预训练模型的输出步幅吗?

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?

  • img的输入形状为:(257,257,3)
  • 输出形状为:(9,9,17)(17个不同关键点的1 [9x9]热图)
  • 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)

推荐答案

输出步幅可从以下公式获得:

The output stride can be obtained from the following equation:

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

示例:输入图像,其宽度 225 像素,而输出 跨度为 16 时,输出大小为 15

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

对于tflite PoseNet模型:

For the tflite PoseNet model:

9 = ((257-1)/ x) + 1 x = 32因此输出步幅为32

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

来源

这篇关于Tensorflow:确定预训练的CNN模型的输出步幅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆