text: import tensorflow  as tf
  import os
  def load_model(model, input_map=None):
      model_exp = os.path.expanduser(model)
  
      print('Model directory: %s' % model_exp)
      meta_file, ckpt_file = get_model_filenames(model_exp)
  
      print('Metagraph file: %s' % meta_file)
      print('Checkpoint file: %s' % ckpt_file)
      with tf.Session() as sess:
          saver = tf.train.import_meta_graph(os.path.join(model_exp, meta_file), input_map=input_map)
          saver.restore(sess, os.path.join(model_exp, ckpt_file))
          tf.summary.FileWriter("/home/hanson/work/Facerecognize_TF/tools",graph=sess.graph)
  
  def get_model_filenames(model_dir):
      files = os.listdir(model_dir)
      meta_files = [s for s in files if s.endswith('.meta')]
      if len(meta_files)==0:
          raise ValueError('No meta file found in the model directory (%s)' % model_dir)
      elif len(meta_files)>1:
          raise ValueError('There should not be more than one meta file in the model directory (%s)' % model_dir)
      meta_file = meta_files[0]
      ckpt = tf.train.get_checkpoint_state(model_dir)
      if ckpt and ckpt.model_checkpoint_path:
          ckpt_file = os.path.basename(ckpt.model_checkpoint_path)
          return meta_file, ckpt_file
  
      meta_files = [s for s in files if '.ckpt' in s]
      max_step = -1
      for f in files:
          step_str = re.match(r'(^model-[\w\- ]+.ckpt-(\d+))', f)
          if step_str is not None and len(step_str.groups())>=2:
              step = int(step_str.groups()[1])
              if step > max_step:
                  max_step = step
                  ckpt_file = step_str.groups()[0]
      return meta_file, ckpt_file
  
  load_model("ToBeConvertModels/checkpoint")