OS: Windows 10
Tensorflow Version: 2.2.0
Model Type: SavedModel (.pb)
Desired Model Type: Tensorflow Lite (.tflite)
I have been going in endless circles trying to find a python script or a command line function to convert a .pb file to .tflite. I have tried using the tflite_convert, but it returns with the error:
OSError: SavedModel file does not exist at: C:/tensorflowTraining/export_dir/saved_model.pb/{saved_model.pbtxt|saved_model.pb}
I have also tried some scripts like:
import tensorflow as to
gf = tf.compat.v1.GraphDef()
m_file = open('saved_model.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())
This returns:
Exception has occurred: DecodeError
Unexpected end-group tag.
This error happens in line 4:
gf.ParseFromString(m_file.read())
It would be really helpful if someone could provide a working script or command line function as many I have researched return errors or do not function properly.
Thank you!