示例#1
0
def _parse_input_meta_graph_proto(input_graph, input_binary):
    """Parser input tensorflow graph into MetaGraphDef proto."""

    if not gfile.Exists(input_graph):

        print("Input meta graph file '" + input_graph + "' does not exist!")

        return -1

    input_meta_graph_def = MetaGraphDef()

    mode = "rb" if input_binary else "r"

    with gfile.FastGFile(input_graph, mode) as f:

        if input_binary:

            input_meta_graph_def.ParseFromString(f.read())

        else:

            text_format.Merge(f.read(), input_meta_graph_def)

    print("Loaded meta graph file '" + input_graph)

    return input_meta_graph_def
示例#2
0
def _parse_input_meta_graph(input_meta_graph):
    """Parse input_meta_graph configurations"""
    if not gfile.Exists(input_meta_graph):
        raise ValueError("Input meta graph file '" + input_meta_graph +
                         "' does not exist.")
    meta_graph_def = MetaGraphDef()
    with gfile.GFile(input_meta_graph, "rb") as f:
        meta_graph_def.ParseFromString(f.read())
    return meta_graph_def