code: def main():
      global_config = config["Global"]
  
      # build model
      model = build_model(config["Architecture"])
      load_model(config, model)
  
      # create data ops
      transforms = []
      for op in config["Eval"]["dataset"]["transforms"]:
          transforms.append(op)
  
      data_dir = config["Eval"]["dataset"]["data_dir"]
  
      ops = create_operators(transforms, global_config)
  
      save_res_path = config["Global"]["save_res_path"]
      class_path = config["Global"]["class_path"]
      idx_to_cls = read_class_list(class_path)
      os.makedirs(os.path.dirname(save_res_path), exist_ok=True)
  
      model.eval()
  
      warmup_times = 0
      count_t = []
      with open(save_res_path, "w") as fout:
          with open(config["Global"]["infer_img"], "rb") as f:
              lines = f.readlines()
              for index, data_line in enumerate(lines):
                  if index == 10:
                      warmup_t = time.time()
                  data_line = data_line.decode("utf-8")
                  substr = data_line.strip("\n").split("\t")
                  img_path, label = (
                      data_dir + "/" + substr[0],
                      substr[1],
                  )
                  data = {"img_path": img_path, "label": label}
                  with open(data["img_path"], "rb") as f:
                      img = f.read()
                      data["image"] = img
                  st = time.time()
                  batch = transform(data, ops)
                  batch_pred = [0] * len(batch)
                  for i in range(len(batch)):
                      batch_pred[i] = paddle.to_tensor(
                          np.expand_dims(batch[i], axis=0)
                      )
                  st = time.time()
                  node, edge = model(batch_pred)
                  node = F.softmax(node, -1)
                  count_t.append(time.time() - st)
                  draw_kie_result(batch, node, idx_to_cls, index)
                  write_kie_result(fout, node, data)
          fout.close()
      logger.info("success!")
      logger.info(
          "It took {} s for predict {} images.".format(
              np.sum(count_t), len(count_t)
          )
      )
      ips = len(count_t[warmup_times:]) / np.sum(count_t[warmup_times:])
      logger.info("The ips is {} images/s".format(ips))
  
file_path: PaddleOCR/tools/infer_kie.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import paddle.nn.functional
  import os
  import sys
  import cv2
  import paddle
  from ppocr.data import create_operators, transform
  from ppocr.modeling.architectures import build_model
  from ppocr.utils.save_load import load_model
  import tools.program
  import time
label_desc: Use image node_id 4 for calling a global function with example usage: main() without return types