def load_graph(frozen_graph_filename):
""" Load graph/model to be used """
logging.info('Loading frozen model-graph: ' + frozen_graph_filename)
# We load the protobuf file from the disk and parse it to retrieve the
# unserialized graph_def
logging.debug('Reading model file')
with tf.gfile.GFile(frozen_graph_filename, "rb") as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
# Then, we can use again a convenient built-in function to import a graph_def into the
# current default Graph
logging.debug('Importing graph')
with tf.Graph().as_default() as graph:
tf.import_graph_def(
graph_def,
input_map=None,
return_elements=None,
name="prefix",
op_dict=None,
producer_op_list=None
)
return graph
评论列表
文章目录