简体   繁体   中英

I cant convert .pb file to .tflite

I need.tflite file to use the model that i trained in android.

I will use this code but i don't know the input array and the output array values:

  tflite_convert \ 
--output_file=object_detection\outputtflite  \ 
--graph_def_file=object_detection\out\frozen_inference_graph.pb\ 
--input_arrays=input\ 
--output_arrays=output

I heard that i can learn input_arrays and output_arrays values from tensorboard but they don't appear in there. I use this code:

tensorboard --logdir=object_detection\out\

There are these errors in my tensorboard screen:

图表 图片

My out folder looks like this:

外文件夹

What can i do about this?

You can use the summarize_graph to inspect the graph. This can help you solve the problem https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/graph_transforms#inspecting-graphs

to check for input_arrays and output_arrays. make a python file inside where frozen_inference_graph.pb folder is located and then paste this code in the py

import tensorflow as tf
gf = tf.GraphDef()
m_file = open('tflite_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())

Once you have run the file it will show the input_arrays and output_arrays.

furthe info check at: How to convert.pb to TFLite format?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM