簡體   English   中英

Tensorflow:確定預訓練 CNN 模型的輸出步幅

[英]Tensorflow: Determine the output stride of a pretrained CNN model

我已經下載並正在使用Tensorflow Lite Posenet 模型實現一個 ML 應用程序。 這個模型的輸出是一個熱圖,它是我剛接觸的 CNN 的一部分。

處理輸出所需的一項信息是“輸出步幅”。 它用於計算在原始圖像中找到的關鍵點的原始坐標。

keypointPositions = heatmapPositions * outputStride + offsetVectors

但是文檔沒有指定輸出步幅。 我可以使用 tensorflow 中的信息或方法來獲取此(任何)預訓練模型的輸出步幅嗎?

  • img 的輸入形狀為: (257,257,3)
  • 輸出形狀為: (9,9,17) (17 個不同關鍵點的 1 [9x9] 熱圖)
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)

可以從以下等式中獲得輸出步幅:

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

示例寬度225像素且輸出步幅為16的輸入圖像導致輸出大小為15

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

對於 tflite PoseNet 模型(分辨率為 9):

9 = ((257-1)/ x) + 1 x = 32所以輸出步幅是 32

來源

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM