def METHOD_NAME(sess, filename):
    # this should be called inside
    # with tf.Session() as sess:
    assert sess
    (_, _, ext) = splitDirFilenameExt(filename)
    if (ext.lower() == 'pb'):
        with tf.gfile.GFile(filename, 'rb') as f:
            graph_def = tf.GraphDef()
            graph_def.ParseFromString(f.read())
    elif (ext.lower() == 'pbtxt'):
        with open(filename, 'r') as reader:
            graph_def = tf.GraphDef()
            text_format.Parse(reader.read(), graph_def)
    else:
        print("# Error: unknown extension - " + ext)
    tf.import_graph_def(graph_def)