Created
November 28, 2019 16:17
-
-
Save MartinNowak/9a2e467d740c43fe7e6fef6c09502449 to your computer and use it in GitHub Desktop.
Convert TF saved model from protobuf binary to text format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
import google.protobuf | |
from tensorflow.core.protobuf import saved_model_pb2 | |
import tensorflow as tf | |
def convert_saved_model_to_pbtxt(path): | |
saved_model = saved_model_pb2.SavedModel() | |
with open(os.path.join(path, 'saved_model.pb'), 'rb') as f: | |
saved_model.ParseFromString(f.read()) | |
with open(os.path.join(path, 'saved_model.pbtxt'), 'w') as f: | |
f.write(google.protobuf.text_format.MessageToString(saved_model)) | |
for path in sys.argv[1:]: | |
convert_saved_model_to_pbtxt(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment