code: def main():
      deploy_file = os.path.join(FLAGS.det_model_dir, "infer_cfg.yml")
      with open(deploy_file) as f:
          yml_conf = yaml.safe_load(f)
      arch = yml_conf["arch"]
      detector_func = "Detector"
      if arch == "PicoDet":
          detector_func = "DetectorPicoDet"
  
      detector = eval(detector_func)(
          FLAGS.det_model_dir,
          device=FLAGS.device,
          run_mode=FLAGS.run_mode,
          trt_min_shape=FLAGS.trt_min_shape,
          trt_max_shape=FLAGS.trt_max_shape,
          trt_opt_shape=FLAGS.trt_opt_shape,
          trt_calib_mode=FLAGS.trt_calib_mode,
          cpu_threads=FLAGS.cpu_threads,
          enable_mkldnn=FLAGS.enable_mkldnn,
          threshold=FLAGS.det_threshold,
      )
  
      topdown_keypoint_detector = KeyPointDetector(
          FLAGS.keypoint_model_dir,
          device=FLAGS.device,
          run_mode=FLAGS.run_mode,
          batch_size=FLAGS.keypoint_batch_size,
          trt_min_shape=FLAGS.trt_min_shape,
          trt_max_shape=FLAGS.trt_max_shape,
          trt_opt_shape=FLAGS.trt_opt_shape,
          trt_calib_mode=FLAGS.trt_calib_mode,
          cpu_threads=FLAGS.cpu_threads,
          enable_mkldnn=FLAGS.enable_mkldnn,
          use_dark=FLAGS.use_dark,
      )
      keypoint_arch = topdown_keypoint_detector.pred_config.arch
      assert (
          KEYPOINT_SUPPORT_MODELS[keypoint_arch] == "keypoint_topdown"
      ), "Detection-Keypoint unite inference only supports topdown models."
  
      # predict from video file or camera video stream
      if FLAGS.video_file is not None or FLAGS.camera_id != -1:
          topdown_unite_predict_video(
              detector,
              topdown_keypoint_detector,
              FLAGS.camera_id,
              FLAGS.keypoint_batch_size,
              FLAGS.save_res,
          )
      else:
          # predict from image
          img_list = get_test_images(FLAGS.image_dir, FLAGS.image_file)
          topdown_unite_predict(
              detector,
              topdown_keypoint_detector,
              img_list,
              FLAGS.keypoint_batch_size,
              FLAGS.save_res,
          )
          if not FLAGS.run_benchmark:
              detector.det_times.info(average=True)
              topdown_keypoint_detector.det_times.info(average=True)
          else:
              mode = FLAGS.run_mode
              det_model_dir = FLAGS.det_model_dir
              det_model_info = {
                  "model_name": det_model_dir.strip("/").split("/")[-1],
                  "precision": mode.split("_")[-1],
              }
              bench_log(detector, img_list, det_model_info, name="Det")
              keypoint_model_dir = FLAGS.keypoint_model_dir
              keypoint_model_info = {
                  "model_name": keypoint_model_dir.strip("/").split(
                      "/"
                  )[-1],
                  "precision": mode.split("_")[-1],
              }
              bench_log(
                  topdown_keypoint_detector,
                  img_list,
                  keypoint_model_info,
                  FLAGS.keypoint_batch_size,
                  "KeyPoint",
              )
  
imports: import os
  import json
  import cv2
  import math
  import numpy
  import paddle
  import yaml
  from det_keypoint_unite_utils import argsparser
  from preprocess import decode_image
  from infer import Detector, DetectorPicoDet, PredictConfig, print_arguments, get_test_images, bench_log
  from keypoint_infer import KeyPointDetector, PredictConfig_KeyPoint
  from visualize import visualize_pose
  from benchmark_utils import PaddleInferBenchmark
  from utils import get_current_memory_mb
  from keypoint_postprocess import translate_to_ori_images
label_desc: Use image node_id 4 for calling a global function with example usage: main() without return types