And*_*ice 3 python android tensorflow
我创建了一个生成.pbtxt文件的Tensorflow模型.我是否可以使用此文件构建Android应用程序,以通过将其重命名为.pb文件来使用生成的模型.
提前致谢.
ash*_*ash 10
如果.pbtxt文件实际上是TensorFlow图的文本表示,那么不,Android API当前不接受它,而是需要图的二进制表示.
也就是说,如果你有这个.pbtxt文件,你可以轻松地将它转换为带有几行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)
Run Code Online (Sandbox Code Playgroud)
或者,如果您控制生成pbtxt文件的管道开头,也许您可以更改它以二进制格式写出文件?
希望有所帮助.
| 归档时间: |
|
| 查看次数: |
6727 次 |
| 最近记录: |