def import_protobuf(self, pb_file, verbose=False):
"""
Imports graph_def from protobuf file to ngraph.
Arguments:
pb_file: Protobuf file path.
verbose: Prints graph_def at each node if True.
"""
# read graph_def
graph_def = tf.GraphDef()
if mimetypes.guess_type(pb_file)[0] == 'text/plain':
with open(pb_file, 'r') as f:
text_format.Merge(f.read(), graph_def)
else:
with open(pb_file, 'rb') as f:
graph_def.ParseFromString(f.read())
self.import_graph_def(graph_def, verbose=verbose)
评论列表
文章目录