Created
March 15, 2018 02:51
-
-
Save alsrgv/1a83c7953cb04676f6a0b3ec3917a18c to your computer and use it in GitHub Desktop.
Converter of graph.pbtxt to binary graph.pb
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
from __future__ import print_function | |
import os | |
import sys | |
import tensorflow as tf | |
from google.protobuf import text_format | |
from tensorflow.python.framework import graph_io | |
if len(sys.argv) < 2: | |
print('Usage: %s <filename prefix>' % sys.argv[0]) | |
sys.exit(-1) | |
filename = sys.argv[1] | |
with open(filename + '.pbtxt', 'r') as f: | |
graph_def = tf.GraphDef() | |
file_content = f.read() | |
text_format.Merge(file_content, graph_def) | |
graph_io.write_graph(graph_def, | |
os.path.dirname(filename), | |
os.path.basename(filename) + '.pb', | |
as_text=False) | |
print('Converted %s.pbtxt to %s.pb' % (filename, filename)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/google/mediapipe/blob/master/mediapipe/framework/encode_binary_proto.bzl