docstr: API for human segmentation.
  
  Args:
      images (list(numpy.ndarray)): images data, shape of each is [H, W, C], the color space is BGR.
      paths (list[str]): The paths of images.
      batch_size (int): batch size.
      use_gpu (bool): Whether to use gpu.
      visualization (bool): Whether to save image or not.
      output_dir (str): The path to store output images.
  
  Returns:
      res (list[dict]): each element in the list is a dict, the keys and values are:
          save_path (str, optional): the path to save images. (Exists only if visualization is True)
          data (numpy.ndarray): data of post processed image.
docstr_tok: ["API","for","human","segmentation",".","Args",":","images","(","list","(","numpy.ndarray",")",")",":","images","data",",","shape","of","each","is","[","H",",","W",",","C","]",",","the","color","space","is","BGR",".","paths","(","list","[","str","]",")",":","The","paths","of","images",".","batch_size","(","int",")",":","batch","size",".","use_gpu","(","bool",")",":","Whether","to","use","gpu",".","visualization","(","bool",")",":","Whether","to","save","image","or","not",".","output_dir","(","str",")",":","The","path","to","store","output","images",".","Returns",":","res","(","list","[","dict","]",")",":","each","element","in","the","list","is","a","dict",",","the","keys","and","values","are",":","save_path","(","str",",","optional",")",":","the","path","to","save","images",".","(","Exists","only","if","visualization","is","True",")","data","(","numpy.ndarray",")",":","data","of","post","processed","image","."]
code: def segment(
      self,
      images=None,
      paths=None,
      batch_size=1,
      use_gpu=False,
      visualization=False,
      output_dir="humanseg_mobile_output",
  ):
      """
      API for human segmentation.
  
      Args:
          images (list(numpy.ndarray)): images data, shape of each is [H, W, C], the color space is BGR.
          paths (list[str]): The paths of images.
          batch_size (int): batch size.
          use_gpu (bool): Whether to use gpu.
          visualization (bool): Whether to save image or not.
          output_dir (str): The path to store output images.
  
      Returns:
          res (list[dict]): each element in the list is a dict, the keys and values are:
              save_path (str, optional): the path to save images. (Exists only if visualization is True)
              data (numpy.ndarray): data of post processed image.
      """
      if use_gpu:
          try:
              _places = os.environ["CUDA_VISIBLE_DEVICES"]
              int(_places[0])
          except:
              raise RuntimeError(
                  "Environment Variable CUDA_VISIBLE_DEVICES is not set correctly."
                  "If you wanna use gpu, please set CUDA_VISIBLE_DEVICES as cuda_device_id."
              )
  
      # compatibility with older versions
  
      all_data = list()
      for yield_data in reader(images, paths):
          all_data.append(yield_data)
      total_num = len(all_data)
      loop_num = int(np.ceil(total_num / batch_size))
      res = list()
      for iter_id in range(loop_num):
          batch_data = list()
          handle_id = iter_id * batch_size
          for image_id in range(batch_size):
              try:
                  batch_data.append(all_data[handle_id + image_id])
              except:
                  pass
          # feed batch image
          batch_image = np.array([data["image"] for data in batch_data])
  
          predictor = (
              self.gpu_predictor if use_gpu else self.cpu_predictor
          )
          input_names = predictor.get_input_names()
          input_handle = predictor.get_input_handle(input_names[0])
          input_handle.copy_from_cpu(batch_image.copy())
          predictor.run()
          output_names = predictor.get_output_names()
          output_handle = predictor.get_output_handle(output_names[1])
          output = output_handle.copy_to_cpu()
  
          output = np.expand_dims(output[:, 1, :, :], axis=1)
          # postprocess one by one
          for i in range(len(batch_data)):
              out = postprocess(
                  data_out=output[i],
                  org_im=batch_data[i]["org_im"],
                  org_im_shape=batch_data[i]["org_im_shape"],
                  org_im_path=batch_data[i]["org_im_path"],
                  output_dir=output_dir,
                  visualization=visualization,
              )
              res.append(out)
      return res
  
imports: import argparse
  import ast
  import os
  import os.path
  import cv2
  import numpy
  import paddle.jit
  import paddle.static
  from paddle.inference import Config
  from paddle.inference import create_predictor
  from .data_feed import preprocess_v
  from .data_feed import reader
  from .optimal import postprocess_v
  from .optimal import threshold_mask
  from .processor import base64_to_cv2
  from .processor import check_dir
  from .processor import cv2_to_base64
  from .processor import postprocess
  from paddlehub.module.module import moduleinfo
  from paddlehub.module.module import runnable
  from paddlehub.module.module import serving
label_desc: Use image node_id 3 for calling the HRNetw18samllv1humanseg obj's underlying member method code with example usage: obj.segment(images, paths, batch_size, use_gpu, visualization, output_dir) and returns: res