code: def eval(args):
      """
      eval mIoU func
      """
      # DataLoader need run on cpu
      paddle.set_device("cpu")
  
      data_cfg = Config(args.config)
      builder = SegBuilder(data_cfg)
  
      eval_dataset = builder.val_dataset
  
      batch_sampler = paddle.io.BatchSampler(
          eval_dataset, batch_size=1, shuffle=False, drop_last=False
      )
      loader = paddle.io.DataLoader(
          eval_dataset,
          batch_sampler=batch_sampler,
          num_workers=0,
          return_list=True,
      )
  
      predictor, rerun_flag = load_predictor(args)
  
      intersect_area_all = 0
      pred_area_all = 0
      label_area_all = 0
      input_names = predictor.get_input_names()
      input_handle = predictor.get_input_handle(input_names[0])
      output_names = predictor.get_output_names()
      output_handle = predictor.get_output_handle(output_names[0])
      total_samples = len(eval_dataset)
      sample_nums = len(loader)
      batch_size = int(total_samples / sample_nums)
      predict_time = 0.0
      time_min = float("inf")
      time_max = float("-inf")
      print(
          "Start evaluating (total_samples: {}, total_iters: {}).".format(
              total_samples, sample_nums
          )
      )
      for batch_id, data in enumerate(loader):
          image = np.array(data["img"])
          label = np.array(data["label"]).astype("int64")
          ori_shape = np.array(label).shape[-2:]
          input_handle.reshape(image.shape)
          input_handle.copy_from_cpu(image)
          start_time = time.time()
          predictor.run()
          results = output_handle.copy_to_cpu()
          end_time = time.time()
          timed = end_time - start_time
          time_min = min(time_min, timed)
          time_max = max(time_max, timed)
          predict_time += timed
          if rerun_flag:
              print(
                  "***** Collect dynamic shape done, Please rerun the program to get correct results. *****"
              )
              return
  
          logit = reverse_transform(
              paddle.to_tensor(results),
              data["trans_info"],
              mode="bilinear",
          )
          pred = paddle.to_tensor(logit)
          if (
              len(pred.shape) == 4
          ):  # for humanseg model whose prediction is distribution but not class id
              pred = paddle.argmax(
                  pred, axis=1, keepdim=True, dtype="int32"
              )
  
          (
              intersect_area,
              pred_area,
              label_area,
          ) = metrics.calculate_area(
              pred,
              paddle.to_tensor(label),
              eval_dataset.num_classes,
              ignore_index=eval_dataset.ignore_index,
          )
          intersect_area_all = intersect_area_all + intersect_area
          pred_area_all = pred_area_all + pred_area
          label_area_all = label_area_all + label_area
          if batch_id % 100 == 0:
              print("Eval iter:", batch_id)
              sys.stdout.flush()
  
      _, miou = metrics.mean_iou(
          intersect_area_all, pred_area_all, label_area_all
      )
      _, acc = metrics.accuracy(intersect_area_all, pred_area_all)
      kappa = metrics.kappa(
          intersect_area_all, pred_area_all, label_area_all
      )
      _, mdice = metrics.dice(
          intersect_area_all, pred_area_all, label_area_all
      )
  
      time_avg = predict_time / sample_nums
      print(
          "[Benchmark]Batch size: {}, Inference time(ms): min={}, max={}, avg={}".format(
              batch_size,
              round(time_min * 1000, 2),
              round(time_max * 1000, 1),
              round(time_avg * 1000, 1),
          )
      )
      infor = "[Benchmark] #Images: {} mIoU: {:.4f} Acc: {:.4f} Kappa: {:.4f} Dice: {:.4f}".format(
          total_samples, miou, acc, kappa, mdice
      )
      print(infor)
      sys.stdout.flush()
  
file_path: PaddleSeg/deploy/slim/act/test_seg.py
imports: import argparse
  import time
  import os
  import sys
  import cv2
  import numpy
  import paddle
  import paddleseg.transforms
  from paddleseg.cvlibs import Config
  from paddleseg.core.infer import reverse_transform
  from paddleseg.utils.visualize import get_pseudo_color_map
  from paddleseg.utils import metrics
  from paddleseg.cvlibs import SegBuilder
  from paddle.inference import create_predictor, PrecisionType
  from paddle.inference import Config
label_desc: Use image node_id 4 for calling a global function with example usage: eval(args) without return types