'Builds the inference graph from serialized GraphDef and SaverDef protos.
Args:
graph_def_file: File containing a serialized GraphDef proto.
saver_def_file: File containing a serialized SaverDef proto.
checkpoint_path: Checkpoint file or a directory containing a checkpoint
file.
Returns:
restore_fn: A function such that restore_fn(sess) loads model variables
from the checkpoint file.'

def build_graph_from_proto(self, graph_def_file, saver_def_file, checkpoint_path):

    tf.logging.info('Loading    GraphDef    from    file:    %s', graph_def_file)
    graph_def = tf.GraphDef()
    with tf.gfile.FastGFile(graph_def_file, 'rb') as f:
        graph_def.ParseFromString(f.read())
    tf.import_graph_def(graph_def, name='')
    tf.logging.info('Loading    SaverDef    from    file:    %s', saver_def_file)
    saver_def = tf.train.SaverDef()
    with tf.gfile.FastGFile(saver_def_file, 'rb') as f:
        saver_def.ParseFromString(f.read())
    saver = tf.train.Saver(saver_def=saver_def)
    return self._create_restore_fn(checkpoint_path, saver)
