def load_graph(model_file, output_nodes_for_freeze=None):
    is_meta = (os.path.splitext(model_file)[(- 1)] == '.meta')
    tf.compat.v1.reset_default_graph()
    graph = tf.Graph()
    graph_def = (tf.compat.v1.GraphDef() if (not is_meta) else tf.compat.v1.MetaGraphDef())
    with open(model_file, 'rb') as f:
        graph_def.ParseFromString(f.read())
    nodes_to_clear_device = (graph_def.node if isinstance(graph_def, tf.compat.v1.GraphDef) else graph_def.graph_def.node)
    for node in nodes_to_clear_device:
        node.device = ''
    if is_meta:
        with tf.compat.v1.Session() as sess:
            restorer = tf.compat.v1.train.import_meta_graph(graph_def)
            restorer.restore(sess, re.sub('\\.meta$', '', model_file))
            graph_def = tf.compat.v1.graph_util.convert_variables_to_constants(sess, graph_def.graph_def, output_nodes_for_freeze)
    with graph.as_default():
        tf.import_graph_def(graph_def, name='')
    return graph
def load_graph(model_file, output_nodes_for_freeze=None):
    is_meta = (os.path.splitext(model_file)[(- 1)] == '.meta')
    tf.compat.v1.reset_default_graph()
    graph = tf.Graph()
    graph_def = (tf.compat.v1.GraphDef() if (not is_meta) else tf.compat.v1.MetaGraphDef())
    with open(model_file, 'rb') as f:
        graph_def.ParseFromString(f.read())
    nodes_to_clear_device = (graph_def.node if isinstance(graph_def, tf.compat.v1.GraphDef) else graph_def.graph_def.node)
    for node in nodes_to_clear_device:
        node.device = 
    if is_meta:
        with tf.compat.v1.Session() as sess:
            restorer = tf.compat.v1.train.import_meta_graph(graph_def)
            restorer.restore(sess, re.sub('\\.meta$', , model_file))
            graph_def = tf.compat.v1.graph_util.convert_variables_to_constants(sess, graph_def.graph_def, output_nodes_for_freeze)
    with graph.as_default():
        tf.import_graph_def(graph_def, name=)
    return graph