class_docstr: Predictor in single camera
  
  The pipeline for image input: 
  
      1. Detection
      2. Detection -> Attribute
  
  The pipeline for video input: 
  
      1. Tracking
      2. Tracking -> Attribute
      3. Tracking -> KeyPoint -> SkeletonAction Recognition
      4. VideoAction Recognition
  
  Args:
      args (argparse.Namespace): arguments in pipeline, which contains environment and runtime settings
      cfg (dict): config of models in pipeline
      is_video (bool): whether the input is video, default as False
      multi_camera (bool): whether to use multi camera in pipeline, 
          default as False
class_docstr_tok: ["Predictor","in","single","camera","The","pipeline","for","image","input",":","1",".","Detection","2",".","Detection","-",">","Attribute","The","pipeline","for","video","input",":","1",".","Tracking","2",".","Tracking","-",">","Attribute","3",".","Tracking","-",">","KeyPoint","-",">","SkeletonAction","Recognition","4",".","VideoAction","Recognition","Args",":","args","(","argparse.Namespace",")",":","arguments","in","pipeline",",","which","contains","environment","and","runtime","settings","cfg","(","dict",")",":","config","of","models","in","pipeline","is_video","(","bool",")",":","whether","the","input","is","video",",","default","as","False","multi_camera","(","bool",")",":","whether","to","use","multi","camera","in","pipeline",",","default","as","False"]
code: def __init__(self, args, cfg, is_video=True, multi_camera=False):
      # general module for pphuman and ppvehicle
      self.with_mot = (
          cfg.get("MOT", False)["enable"]
          if cfg.get("MOT", False)
          else False
      )
      self.with_human_attr = (
          cfg.get("ATTR", False)["enable"]
          if cfg.get("ATTR", False)
          else False
      )
      if self.with_mot:
          print("Multi-Object Tracking enabled")
      if self.with_human_attr:
          print("Human Attribute Recognition enabled")
  
      # only for pphuman
      self.with_skeleton_action = (
          cfg.get("SKELETON_ACTION", False)["enable"]
          if cfg.get("SKELETON_ACTION", False)
          else False
      )
      self.with_video_action = (
          cfg.get("VIDEO_ACTION", False)["enable"]
          if cfg.get("VIDEO_ACTION", False)
          else False
      )
      self.with_idbased_detaction = (
          cfg.get("ID_BASED_DETACTION", False)["enable"]
          if cfg.get("ID_BASED_DETACTION", False)
          else False
      )
      self.with_idbased_clsaction = (
          cfg.get("ID_BASED_CLSACTION", False)["enable"]
          if cfg.get("ID_BASED_CLSACTION", False)
          else False
      )
      self.with_mtmct = (
          cfg.get("REID", False)["enable"]
          if cfg.get("REID", False)
          else False
      )
  
      if self.with_skeleton_action:
          print("SkeletonAction Recognition enabled")
      if self.with_video_action:
          print("VideoAction Recognition enabled")
      if self.with_idbased_detaction:
          print("IDBASED Detection Action Recognition enabled")
      if self.with_idbased_clsaction:
          print("IDBASED Classification Action Recognition enabled")
      if self.with_mtmct:
          print("MTMCT enabled")
  
      # only for ppvehicle
      self.with_vehicleplate = (
          cfg.get("VEHICLE_PLATE", False)["enable"]
          if cfg.get("VEHICLE_PLATE", False)
          else False
      )
      if self.with_vehicleplate:
          print("Vehicle Plate Recognition enabled")
  
      self.with_vehicle_attr = (
          cfg.get("VEHICLE_ATTR", False)["enable"]
          if cfg.get("VEHICLE_ATTR", False)
          else False
      )
      if self.with_vehicle_attr:
          print("Vehicle Attribute Recognition enabled")
  
      self.with_vehicle_press = (
          cfg.get("VEHICLE_PRESSING", False)["enable"]
          if cfg.get("VEHICLE_PRESSING", False)
          else False
      )
      if self.with_vehicle_press:
          print("Vehicle Pressing Recognition enabled")
  
      self.with_vehicle_retrograde = (
          cfg.get("VEHICLE_RETROGRADE", False)["enable"]
          if cfg.get("VEHICLE_RETROGRADE", False)
          else False
      )
      if self.with_vehicle_retrograde:
          print("Vehicle Retrograde Recognition enabled")
  
      self.modebase = {
          "framebased": False,
          "videobased": False,
          "idbased": False,
          "skeletonbased": False,
      }
  
      self.basemode = {
          "MOT": "idbased",
          "ATTR": "idbased",
          "VIDEO_ACTION": "videobased",
          "SKELETON_ACTION": "skeletonbased",
          "ID_BASED_DETACTION": "idbased",
          "ID_BASED_CLSACTION": "idbased",
          "REID": "idbased",
          "VEHICLE_PLATE": "idbased",
          "VEHICLE_ATTR": "idbased",
          "VEHICLE_PRESSING": "idbased",
          "VEHICLE_RETROGRADE": "idbased",
      }
  
      self.is_video = is_video
      self.multi_camera = multi_camera
      self.cfg = cfg
  
      self.output_dir = args.output_dir
      self.draw_center_traj = args.draw_center_traj
      self.secs_interval = args.secs_interval
      self.do_entrance_counting = args.do_entrance_counting
      self.do_break_in_counting = args.do_break_in_counting
      self.region_type = args.region_type
      self.region_polygon = args.region_polygon
      self.illegal_parking_time = args.illegal_parking_time
  
      self.warmup_frame = self.cfg["warmup_frame"]
      self.pipeline_res = Result()
      self.pipe_timer = PipeTimer()
      self.file_name = None
      self.collector = DataCollector()
  
      self.pushurl = args.pushurl
  
      # auto download inference model
      get_model_dir(self.cfg)
  
      if self.with_vehicleplate:
          vehicleplate_cfg = self.cfg["VEHICLE_PLATE"]
          self.vehicleplate_detector = PlateRecognizer(
              args, vehicleplate_cfg
          )
          basemode = self.basemode["VEHICLE_PLATE"]
          self.modebase[basemode] = True
  
      if self.with_human_attr:
          attr_cfg = self.cfg["ATTR"]
          basemode = self.basemode["ATTR"]
          self.modebase[basemode] = True
          self.attr_predictor = AttrDetector.init_with_cfg(
              args, attr_cfg
          )
  
      if self.with_vehicle_attr:
          vehicleattr_cfg = self.cfg["VEHICLE_ATTR"]
          basemode = self.basemode["VEHICLE_ATTR"]
          self.modebase[basemode] = True
          self.vehicle_attr_predictor = VehicleAttr.init_with_cfg(
              args, vehicleattr_cfg
          )
  
      if self.with_vehicle_press:
          vehiclepress_cfg = self.cfg["VEHICLE_PRESSING"]
          basemode = self.basemode["VEHICLE_PRESSING"]
          self.modebase[basemode] = True
          self.vehicle_press_predictor = VehiclePressingRecognizer(
              vehiclepress_cfg
          )
  
      if self.with_vehicle_press or self.with_vehicle_retrograde:
          laneseg_cfg = self.cfg["LANE_SEG"]
          self.laneseg_predictor = LaneSegPredictor(
              laneseg_cfg["lane_seg_config"], laneseg_cfg["model_dir"]
          )
  
      if not is_video:
          det_cfg = self.cfg["DET"]
          model_dir = det_cfg["model_dir"]
          batch_size = det_cfg["batch_size"]
          self.det_predictor = Detector(
              model_dir,
              args.device,
              args.run_mode,
              batch_size,
              args.trt_min_shape,
              args.trt_max_shape,
              args.trt_opt_shape,
              args.trt_calib_mode,
              args.cpu_threads,
              args.enable_mkldnn,
          )
      else:
          if self.with_idbased_detaction:
              idbased_detaction_cfg = self.cfg["ID_BASED_DETACTION"]
              basemode = self.basemode["ID_BASED_DETACTION"]
              self.modebase[basemode] = True
  
              self.det_action_predictor = (
                  DetActionRecognizer.init_with_cfg(
                      args, idbased_detaction_cfg
                  )
              )
              self.det_action_visual_helper = ActionVisualHelper(1)
  
          if self.with_idbased_clsaction:
              idbased_clsaction_cfg = self.cfg["ID_BASED_CLSACTION"]
              basemode = self.basemode["ID_BASED_CLSACTION"]
              self.modebase[basemode] = True
  
              self.cls_action_predictor = (
                  ClsActionRecognizer.init_with_cfg(
                      args, idbased_clsaction_cfg
                  )
              )
              self.cls_action_visual_helper = ActionVisualHelper(1)
  
          if self.with_skeleton_action:
              skeleton_action_cfg = self.cfg["SKELETON_ACTION"]
              display_frames = skeleton_action_cfg["display_frames"]
              self.coord_size = skeleton_action_cfg["coord_size"]
              basemode = self.basemode["SKELETON_ACTION"]
              self.modebase[basemode] = True
              skeleton_action_frames = skeleton_action_cfg["max_frames"]
  
              self.skeleton_action_predictor = (
                  SkeletonActionRecognizer.init_with_cfg(
                      args, skeleton_action_cfg
                  )
              )
              self.skeleton_action_visual_helper = ActionVisualHelper(
                  display_frames
              )
  
              kpt_cfg = self.cfg["KPT"]
              kpt_model_dir = kpt_cfg["model_dir"]
              kpt_batch_size = kpt_cfg["batch_size"]
              self.kpt_predictor = KeyPointDetector(
                  kpt_model_dir,
                  args.device,
                  args.run_mode,
                  kpt_batch_size,
                  args.trt_min_shape,
                  args.trt_max_shape,
                  args.trt_opt_shape,
                  args.trt_calib_mode,
                  args.cpu_threads,
                  args.enable_mkldnn,
                  use_dark=False,
              )
              self.kpt_buff = KeyPointBuff(skeleton_action_frames)
  
          if self.with_vehicleplate:
              vehicleplate_cfg = self.cfg["VEHICLE_PLATE"]
              self.vehicleplate_detector = PlateRecognizer(
                  args, vehicleplate_cfg
              )
              basemode = self.basemode["VEHICLE_PLATE"]
              self.modebase[basemode] = True
  
          if self.with_mtmct:
              reid_cfg = self.cfg["REID"]
              basemode = self.basemode["REID"]
              self.modebase[basemode] = True
              self.reid_predictor = ReID.init_with_cfg(args, reid_cfg)
  
          if self.with_vehicle_retrograde:
              vehicleretrograde_cfg = self.cfg["VEHICLE_RETROGRADE"]
              basemode = self.basemode["VEHICLE_RETROGRADE"]
              self.modebase[basemode] = True
              self.vehicle_retrograde_predictor = (
                  VehicleRetrogradeRecognizer(vehicleretrograde_cfg)
              )
  
          if (
              self.with_mot
              or self.modebase["idbased"]
              or self.modebase["skeletonbased"]
          ):
              mot_cfg = self.cfg["MOT"]
              model_dir = mot_cfg["model_dir"]
              tracker_config = mot_cfg["tracker_config"]
              batch_size = mot_cfg["batch_size"]
              skip_frame_num = mot_cfg.get("skip_frame_num", -1)
              basemode = self.basemode["MOT"]
              self.modebase[basemode] = True
              self.mot_predictor = SDE_Detector(
                  model_dir,
                  tracker_config,
                  args.device,
                  args.run_mode,
                  batch_size,
                  args.trt_min_shape,
                  args.trt_max_shape,
                  args.trt_opt_shape,
                  args.trt_calib_mode,
                  args.cpu_threads,
                  args.enable_mkldnn,
                  skip_frame_num=skip_frame_num,
                  draw_center_traj=self.draw_center_traj,
                  secs_interval=self.secs_interval,
                  do_entrance_counting=self.do_entrance_counting,
                  do_break_in_counting=self.do_break_in_counting,
                  region_type=self.region_type,
                  region_polygon=self.region_polygon,
              )
  
          if self.with_video_action:
              video_action_cfg = self.cfg["VIDEO_ACTION"]
              basemode = self.basemode["VIDEO_ACTION"]
              self.modebase[basemode] = True
              self.video_action_predictor = (
                  VideoActionRecognizer.init_with_cfg(
                      args, video_action_cfg
                  )
              )
  
imports: import os
  import yaml
  import glob
  import cv2
  import numpy
  import math
  import paddle
  import sys
  import copy
  import threading
  import queue
  import time
  from collections import defaultdict
  from datacollector import DataCollector, Result
  from cfg_utils import argsparser, print_arguments, merge_cfg
  from pipe_utils import PipeTimer
  from pipe_utils import get_test_images, crop_image_with_det, crop_image_with_mot, parse_mot_res, parse_mot_keypoint
  from pipe_utils import PushStream
  from python.infer import Detector, DetectorPicoDet
  from python.keypoint_infer import KeyPointDetector
  from python.keypoint_postprocess import translate_to_ori_images
  from python.preprocess import decode_image, ShortSizeScale
  from python.visualize import visualize_box_mask, visualize_attr, visualize_pose, visualize_action, visualize_vehicleplate, visualize_vehiclepress, visualize_lane, visualize_vehicle_retrograde
  from pptracking.python.mot_sde_infer import SDE_Detector
  from pptracking.python.mot.visualize import plot_tracking_dict
  from pptracking.python.mot.utils import flow_statistic, update_object_info
  from pphuman.attr_infer import AttrDetector
  from pphuman.video_action_infer import VideoActionRecognizer
  from pphuman.action_infer import SkeletonActionRecognizer, DetActionRecognizer, ClsActionRecognizer
  from pphuman.action_utils import KeyPointBuff, ActionVisualHelper
  from pphuman.reid import ReID
  from pphuman.mtmct import mtmct_process
  from ppvehicle.vehicle_plate import PlateRecognizer
  from ppvehicle.vehicle_attr import VehicleAttr
  from ppvehicle.vehicle_pressing import VehiclePressingRecognizer
  from ppvehicle.vehicle_retrograde import VehicleRetrogradeRecognizer
  from ppvehicle.lane_seg_infer import LaneSegPredictor
  from download import auto_download_model
label_desc: Use image node_id 1 to create a new PipePredictor object from inherited base classes: object with example: obj = PipePredictor(args, cfg, is_video, multi_camera)