def run_inference(self, ckpt_dir, image_files, labels):
    """Build and run inference on the target images and labels."""
    with tf.Graph().as_default(), tf.Session() as sess:
      images, labels = self.build_dataset(image_files, labels, False)
      probs = self.build_model(images, is_training=False)

      sess.run(tf.global_variables_initializer())
      self.restore_model(sess, ckpt_dir)

      prediction_idx = []
      prediction_prob = []
      for _ in range(len(image_files) // self.batch_size):
        out_probs = sess.run(probs)
        idx = np.argsort(out_probs)[::-1]
        prediction_idx.append(idx[:5])
        prediction_prob.append([out_probs[pid] for pid in idx[:5]])

      # Return the top 5 predictions (idx and prob) for each image.
      return prediction_idx, prediction_prob
Build and run inference on the target images and labels.
tf_to_pytorch/convert_tf_to_pt/original_tf/eval_ckpt_main.py