docstr: Get the input and program of the infer model
  
  Args:
       image (str): image path
       use_gpu(bool): Weather to use gpu
docstr_tok: ["Get","the","input","and","program","of","the","infer","model","Args",":","image","(","str",")",":","image","path","use_gpu","(","bool",")",":","Weather","to","use","gpu"]
code: def ExtractLine(self, image, use_gpu=False):
      """
      Get the input and program of the infer model
  
      Args:
           image (str): image path
           use_gpu(bool): Weather to use gpu
      """
      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."
              )
  
      from_mat = cv2.imread(image)
      width = float(from_mat.shape[1])
      height = float(from_mat.shape[0])
      new_width = 0
      new_height = 0
      if width > height:
          from_mat = cv2.resize(
              from_mat,
              (512, int(512 / width * height)),
              interpolation=cv2.INTER_AREA,
          )
          new_width = 512
          new_height = int(512 / width * height)
      else:
          from_mat = cv2.resize(
              from_mat,
              (int(512 / height * width), 512),
              interpolation=cv2.INTER_AREA,
          )
          new_width = int(512 / height * width)
          new_height = 512
  
      from_mat = from_mat.transpose((2, 0, 1))
      light_map = np.zeros(from_mat.shape, dtype=np.float32)
      for channel in range(3):
          light_map[channel] = get_light_map_single(from_mat[channel])
      light_map = normalize_pic(light_map)
      light_map = resize_img_512_3d(light_map)
      light_map = light_map.astype("float32")
  
      # 获取模型的输入输出
      if use_gpu:
          self.predictor = self.gpu_predictor
      else:
          self.predictor = self.cpu_predictor
  
      self.input_names = self.predictor.get_input_names()
      self.output_names = self.predictor.get_output_names()
      self.input_handle = self.predictor.get_input_handle(
          self.input_names[0]
      )
      self.output_handle = self.predictor.get_output_handle(
          self.output_names[0]
      )
      line_mat = self.predict(
          np.expand_dims(light_map, axis=0).astype("float32")
      )
      # 去除 batch 维度 (512, 512, 3)
      line_mat = line_mat.transpose((3, 1, 2, 0))[0]
      # 裁剪 (512, 384, 3)
      line_mat = line_mat[0 : int(new_height), 0 : int(new_width), :]
      line_mat = np.amax(line_mat, 2)
      # 保存图片
      if Path("./output/").exists():
          show_active_img_and_save_denoise(
              line_mat, "./output/" + "output.png"
          )
      else:
          os.makedirs("./output/")
          show_active_img_and_save_denoise(
              line_mat, "./output/" + "output.png"
          )
      print("图片已经完成")
  
file_path: PaddleHub/modules/image/semantic_segmentation/Extract_Line_Draft/module.py
imports: import argparse
  import ast
  import os
  import cv2
  from pathlib import Path
  from paddle.inference import Config, create_predictor
  from paddlehub.module.module import runnable, moduleinfo
  import numpy
  from .function import get_light_map_single, normalize_pic, resize_img_512_3d, show_active_img_and_save_denoise
label_desc: Use image node_id 4 for calling the ExtractLineDraft obj's underlying member method code with example usage: obj.ExtractLine(image, use_gpu) without return types