code: def main():
      detector = AttrDetector(
          FLAGS.model_dir,
          device=FLAGS.device,
          run_mode=FLAGS.run_mode,
          batch_size=FLAGS.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,
          threshold=FLAGS.threshold,
          output_dir=FLAGS.output_dir,
      )
  
      # predict from image
      if FLAGS.image_dir is None and FLAGS.image_file is not None:
          assert (
              FLAGS.batch_size == 1
          ), "batch_size should be 1, when image_file is not None"
      img_list = get_test_images(FLAGS.image_dir, FLAGS.image_file)
      detector.predict_image(img_list, FLAGS.run_benchmark, repeats=10)
      if not FLAGS.run_benchmark:
          detector.det_times.info(average=True)
      else:
          mems = {
              "cpu_rss_mb": detector.cpu_mem / len(img_list),
              "gpu_rss_mb": detector.gpu_mem / len(img_list),
              "gpu_util": detector.gpu_util * 100 / len(img_list),
          }
  
          perf_info = detector.det_times.report(average=True)
          model_dir = FLAGS.model_dir
          mode = FLAGS.run_mode
          model_info = {
              "model_name": model_dir.strip("/").split("/")[-1],
              "precision": mode.split("_")[-1],
          }
          data_info = {
              "batch_size": FLAGS.batch_size,
              "shape": "dynamic_shape",
              "data_num": perf_info["img_num"],
          }
          det_log = PaddleInferBenchmark(
              detector.config, model_info, data_info, perf_info, mems
          )
          det_log("Attr")
  
imports: import os
  import yaml
  import glob
  from functools import reduce
  import cv2
  import numpy
  import math
  import paddle
  from paddle.inference import Config
  from paddle.inference import create_predictor
  import sys
  from python.benchmark_utils import PaddleInferBenchmark
  from python.preprocess import preprocess, Resize, NormalizeImage, Permute, PadStride, LetterBoxResize, WarpAffine
  from python.visualize import visualize_attr
  from python.utils import argsparser, Timer, get_current_memory_mb
  from python.infer import Detector, get_test_images, print_arguments, load_predictor
  from PIL import Image, ImageDraw, ImageFont
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types