Tensor2tensor: Export/Server tensor2tensor as a .pb file instead of .pbtxt

Created on 6 Jun 2018  路  8Comments  路  Source: tensorflow/tensor2tensor

Description

I would like to know how to export the tensor2tensor serving as a .pb file, rather than a .pbtxt file.

Alternately, how can I get the output node names from the checkpoints/.pbtxt file?
...

tensor2tensor==1.6.3
tensorflow==1.8.0

OS: CentOS

Python 2.7.5

For bugs: reproduction and error logs

# Steps to reproduce:
...
# Error logs:
...
question

Most helpful comment

@marcbelmont Is it possible to freeze the savedmodel files (.pbtxt and variables) into .pb for mobile or embedded applications? I have got the same error in the process of doing that: google.protobuf.text_format.ParseError: 1:1 : Message type "tensorflow.GraphDef" has no field named "saved_model_schema_version".

All 8 comments

The tensor2tensor trainer doesn't appear to package this feature as an argument or flag, nonetheless, it is possible using ash's answer from stack overflow:

`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)`

Thanks @Littlenova

@Littlenova, I tried it and it says:

google.protobuf.text_format.ParseError: 1:1 : Message type "tensorflow.GraphDef" has no field named "saved_model_schema_version".

I tried it on the .pbtxt which was created using tensor2tensor.serving.export

Yes, I am facing the same issue too.

+1

google.protobuf.text_format.ParseError: 1:1 : 
Message type "tensorflow.GraphDef" has no field named "saved_model_schema_version".

Actually the format is closer to MetaGraphDef (but not exactly). Export file should be used with tensorflow-model-server as described in https://github.com/tensorflow/tensor2tensor/tree/v1.9.0/tensor2tensor/serving

@marcbelmont Is it possible to freeze the savedmodel files (.pbtxt and variables) into .pb for mobile or embedded applications? I have got the same error in the process of doing that: google.protobuf.text_format.ParseError: 1:1 : Message type "tensorflow.GraphDef" has no field named "saved_model_schema_version".

@marcbelmont Is it possible to freeze the savedmodel files (.pbtxt and variables) into .pb for mobile or embedded applications? I have got the same error in the process of doing that: google.protobuf.text_format.ParseError: 1:1 : Message type "tensorflow.GraphDef" has no field named "saved_model_schema_version".
I also encountered this problem. Have you solved it? ask for help. please
my wechat rensheng_1994
mail:[email protected]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

draplater picture draplater  路  4Comments

SapphireEmbers picture SapphireEmbers  路  3Comments

bezigon picture bezigon  路  4Comments

sebastian-nehrdich picture sebastian-nehrdich  路  4Comments

KayShenClarivate picture KayShenClarivate  路  3Comments