code: def run(self, imgs, trimaps=None, imgs_dir=None):
      self.imgs_dir = imgs_dir
      num = len(imgs)
      input_names = self.predictor.get_input_names()
      input_handle = {}
  
      for i in range(len(input_names)):
          input_handle[
              input_names[i]
          ] = self.predictor.get_input_handle(input_names[i])
      output_names = self.predictor.get_output_names()
      output_handle = {}
      output_handle["alpha"] = self.predictor.get_output_handle(
          output_names[0]
      )
      output_handle["fg"] = self.predictor.get_output_handle(
          output_names[1]
      )
      output_handle["r1"] = self.predictor.get_output_handle(
          output_names[2]
      )
      output_handle["r2"] = self.predictor.get_output_handle(
          output_names[3]
      )
      output_handle["r3"] = self.predictor.get_output_handle(
          output_names[4]
      )
      output_handle["r4"] = self.predictor.get_output_handle(
          output_names[5]
      )
  
      args = self.args
  
      for i in tqdm.tqdm(range(0, num, args.batch_size)):
          # warm up
          if i == 0 and args.benchmark:
              for _ in range(5):
                  img_inputs = []
                  if trimaps is not None:
                      trimap_inputs = []
                  trans_info = []
                  for j in range(i, i + args.batch_size):
                      img = imgs[j]
                      data = self._preprocess(img=img)
                      img_inputs.append(data["img"])
                      trans_info.append(data["trans_info"])
                  img_inputs = np.array(img_inputs)
                  n, _, h, w = img_inputs.shape
                  downsample_ratio = min(512 / max(h, w), 1)
                  downsample_ratio = np.array(
                      [downsample_ratio], dtype="float32"
                  )
  
                  input_handle["img"].copy_from_cpu(img_inputs)
                  input_handle["downsample_ratio"].copy_from_cpu(
                      downsample_ratio.astype("float32")
                  )
                  r_channels = [16, 20, 40, 64]
                  for k in range(4):
                      j = k + 1
                      hj = int(
                          np.ceil(int(h * downsample_ratio[0]) / 2**j)
                      )
                      wj = int(
                          np.ceil(int(w * downsample_ratio[0]) / 2**j)
                      )
                      rj = np.zeros(
                          (n, r_channels[k], hj, wj), dtype="float32"
                      )
                      input_handle["r" + str(j)].copy_from_cpu(rj)
  
                  self.predictor.run()
                  alphas = output_handle["alpha"].copy_to_cpu()
                  fgs = output_handle["fg"].copy_to_cpu()
                  alphas = alphas.squeeze(1)
                  for j in range(args.batch_size):
                      alpha = self._postprocess(
                          alphas[j], trans_info[j]
                      )
                      fg = fgs[j]
                      fg = np.transpose(fg, (1, 2, 0))
                      fg = self._postprocess(fg, trans_info[j])
  
          # inference
          if args.benchmark:
              self.autolog.times.start()
  
          img_inputs = []
          if trimaps is not None:
              trimap_inputs = []
          trans_info = []
          for j in range(i, i + args.batch_size):
              img = imgs[j]
              data = self._preprocess(img=img)
              img_inputs.append(data["img"])
              trans_info.append(data["trans_info"])
          img_inputs = np.array(img_inputs)
          n, _, h, w = img_inputs.shape
          downsample_ratio = min(512 / max(h, w), 1)
          downsample_ratio = np.array(
              [downsample_ratio], dtype="float32"
          )
  
          input_handle["img"].copy_from_cpu(img_inputs)
          input_handle["downsample_ratio"].copy_from_cpu(
              downsample_ratio.astype("float32")
          )
          r_channels = [16, 20, 40, 64]
          for k in range(4):
              j = k + 1
              hj = int(np.ceil(int(h * downsample_ratio[0]) / 2**j))
              wj = int(np.ceil(int(w * downsample_ratio[0]) / 2**j))
              rj = np.zeros((n, r_channels[k], hj, wj), dtype="float32")
              input_handle["r" + str(j)].copy_from_cpu(rj)
  
          if args.benchmark:
              self.autolog.times.stamp()
  
          self.predictor.run()
          alphas = output_handle["alpha"].copy_to_cpu()
          fgs = output_handle["fg"].copy_to_cpu()
  
          if args.benchmark:
              self.autolog.times.stamp()
  
          alphas = alphas.squeeze(1)
          for j in range(args.batch_size):
              alpha = self._postprocess(alphas[j], trans_info[j])
              fg = fgs[j]
              fg = np.transpose(fg, (1, 2, 0))
              fg = self._postprocess(fg, trans_info[j])
              self._save_imgs(alpha, fg=fg, img_path=imgs[i + j])
  
          if args.benchmark:
              self.autolog.times.end(stamp=True)
      logger.info("Finish")
  
imports: import argparse
  import codecs
  import os
  import sys
  import cv2
  import tqdm
  import yaml
  import numpy
  import paddle
  from paddle.inference import create_predictor, PrecisionType
  from paddle.inference import Config
  from paddleseg.cvlibs import manager
  from paddleseg.utils import get_sys_env, logger
  import ppmatting.transforms
  from ppmatting.utils import get_image_list, mkdir, estimate_foreground_ml, VideoReader, VideoWriter
label_desc: Use image node_id 2 for calling the PredictorRVM obj's underlying member method code with example usage: obj.run(imgs, trimaps, imgs_dir) without return types