问题描述
我下载了我在 Azure 认知服务中训练的模型的 retrained_graph.pb
和 retrained_labels.txt
文件.现在我想使用该模型制作一个 Android 应用程序,为此我必须将其转换为 TFLite 格式.我使用了 toco,但出现以下错误:
I downloaded a retrained_graph.pb
and retrained_labels.txt
file of a model I trained in Azure cognitive service. Now I want to make an Android app using that model and to do so I have to convert it to TFLite format. I used toco and I am getting the following error:
ValueError: Invalid tensors 'input' were found.
我基本上是按照本教程进行的,并且在第 4 步中遇到问题并且直接复制粘贴终端代码:https://heartbeat.fritz.ai/neural-networks-on-mobile-devices-with-tensorflow-lite-a-tutorial-85b41f53230c
I am basically following this tutorial and have problem on step 4 and direclycopy pasted the terminal code:https://heartbeat.fritz.ai/neural-networks-on-mobile-devices-with-tensorflow-lite-a-tutorial-85b41f53230c
推荐答案
我在这里胡乱猜测,也许您输入了 input_arrays=input
.这可能不是真的.使用此脚本查找冻结推理图的输入和输出数组的名称
I am making a wild guess here, maybe you entered input_arrays=input
.Which may not be true. Use this script to find the name of the input and output arrays of the frozen inference graph
import tensorflow as tf
gf = tf.GraphDef()
m_file = open('frozen_inference_graph.pb','rb')
gf.ParseFromString(m_file.read())
with open('somefile.txt', 'a') as the_file:
for n in gf.node:
the_file.write(n.name+'\n')
file = open('somefile.txt','r')
data = file.readlines()
print "output name = "
print data[len(data)-1]
print "Input name = "
file.seek ( 0 )
print file.readline()
就我而言,它们是:
output name: SemanticPredictions
input name: ImageTensor
这篇关于如何将 .pb 转换为 TFLite 格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!