I created a Tensorflow model which generated .pbtxt file. Can I use this file in building Android Application to use the generated model by renaming it to .pb file.
Thanks in Advance.
If the .pbtxt
file is really a textual representation of the TensorFlow graph, then no, the Android APIs currently do not accept that and instead require a binary representation of the graph.
That said, if you have the .pbtxt
file, you can easily convert it to a binary protocol buffer with a few lines of Python:
import tensorflow as tf
from google.protobuf import text_format
with open('/tmp/myfile.pbtxt') as f:
txt = f.read()
gdef = text_format.Parse(txt, tf.GraphDef())
tf.train.write_graph(gdef, '/tmp', 'myfile.pb', as_text=False)
Alternatively, if you control the pipeline that generated the pbtxt
file to begin with, perhaps you could change that to write out the file in binary format?
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With