docstr: Prepare for prediction.
  The usage and docs of paddle inference, please refer to
  https://paddleinference.paddlepaddle.org.cn/product_introduction/summary.html
docstr_tok: ["Prepare","for","prediction",".","The","usage","and","docs","of","paddle","inference",",","please","refer","to","https",":","\/\/paddleinference.paddlepaddle.org.cn\/product_introduction\/summary.html"]
code: def __init__(self, lane_seg_config, model_dir):
      """
      Prepare for prediction.
      The usage and docs of paddle inference, please refer to
      https://paddleinference.paddlepaddle.org.cn/product_introduction/summary.html
      """
      if not os.path.exists(lane_seg_config):
          raise ValueError("Cannot find : {},".format(lane_seg_config))
  
      args = yaml.safe_load(open(lane_seg_config))
      self.model_dir = model_dir
      self.args = args[args["type"]]
  
      self.shape = None
      self.filter_horizontal_flag = self.args["filter_horizontal_flag"]
      self.horizontal_filtration_degree = self.args[
          "horizontal_filtration_degree"
      ]
      self.horizontal_filtering_threshold = self.args[
          "horizontal_filtering_threshold"
      ]
  
      try:
          self.predictor, _ = load_predictor(
              model_dir=self.model_dir,
              run_mode=self.args["run_mode"],
              batch_size=self.args["batch_size"],
              device=self.args["device"],
              min_subgraph_size=self.args["min_subgraph_size"],
              use_dynamic_shape=self.args["use_dynamic_shape"],
              trt_min_shape=self.args["trt_min_shape"],
              trt_max_shape=self.args["trt_max_shape"],
              trt_opt_shape=self.args["trt_opt_shape"],
              trt_calib_mode=self.args["trt_calib_mode"],
              cpu_threads=self.args["cpu_threads"],
              enable_mkldnn=self.args["enable_mkldnn"],
          )
      except Exception as e:
          print(str(e))
          exit()
  
imports: import argparse
  import codecs
  import os
  import yaml
  import numpy
  import cv2
  from sklearn.cluster import DBSCAN
  from pptracking.python.det_infer import load_predictor
label_desc: Use image node_id 1 to create a new LaneSegPredictor object  with example: obj = LaneSegPredictor(lane_seg_config, model_dir)