docstr: Read the data from dataset and calculate the accurary of the inference model.
docstr_tok: ["Read","the","data","from","dataset","and","calculate","the","accurary","of","the","inference","model","."]
code: def run_dataset(self):
      """
      Read the data from dataset and calculate the accurary of the inference model.
      """
      dataset = get_dataset(self.args)
  
      input_names = self.predictor.get_input_names()
      input_handle = self.predictor.get_input_handle(input_names[0])
      output_names = self.predictor.get_output_names()
      output_handle = self.predictor.get_output_handle(output_names[0])
  
      intersect_area_all = 0
      pred_area_all = 0
      label_area_all = 0
      total_time = 0
      progbar_val = progbar.Progbar(target=len(dataset), verbose=1)
  
      for idx, (img, label) in enumerate(dataset):
          data = np.array([img])
          check_shape(data.shape, args)
          input_handle.reshape(data.shape)
          input_handle.copy_from_cpu(data)
  
          start_time = time.time()
          self.predictor.run()
          pred = output_handle.copy_to_cpu()
          end_time = time.time()
          total_time += end_time - start_time
  
          pred = self._postprocess(pred)
          pred = paddle.to_tensor(pred, dtype="int64")
          label = paddle.to_tensor(label, dtype="int32")
          if pred.shape != label.shape:
              label = paddle.unsqueeze(label, 0)
              label = F.interpolate(label, pred.shape[-2:])
              label = paddle.squeeze(label, 0)
  
          (
              intersect_area,
              pred_area,
              label_area,
          ) = metrics.calculate_area(
              pred,
              label,
              dataset.num_classes,
              ignore_index=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
  
          progbar_val.update(idx + 1)
  
      class_iou, miou = metrics.mean_iou(
          intersect_area_all, pred_area_all, label_area_all
      )
      class_acc, acc = metrics.accuracy(
          intersect_area_all, pred_area_all
      )
      kappa = metrics.kappa(
          intersect_area_all, pred_area_all, label_area_all
      )
  
      logger.info(
          "input width: {}, input height: {}".format(
              args.resize_width, args.resize_height
          )
      )
      logger.info(
          "[EVAL] #Images: {} mIoU: {:.4f} Acc: {:.4f} Kappa: {:.4f} ".format(
              len(dataset), miou, acc, kappa
          )
      )
      logger.info("[EVAL] Class IoU: \n" + str(np.round(class_iou, 4)))
      logger.info("[EVAL] Class Acc: \n" + str(np.round(class_acc, 4)))
      logger.info(
          "[EVAL] Average time: %.3f ms/img"
          % (total_time * 1000.0 / len(dataset))
      )
  
imports: import argparse
  import codecs
  import os
  import time
  import yaml
  import numpy
  import paddle
  import paddle.nn.functional
  from paddle.inference import create_predictor
  from paddle.inference import Config
  from paddleseg.deploy.infer import DeployConfig
  from paddleseg.cvlibs import manager
  from paddleseg.utils import logger, metrics, progbar
  from infer import auto_tune, use_auto_tune, Predictor
label_desc: Use image node_id 2 for calling the DatasetPredictor obj's underlying member method code with example usage: obj.run_dataset() without return types