code: def run(FLAGS, cfg):
      ssod_method = cfg.get("ssod_method", None)
      if ssod_method == "ARSL":
          trainer = Trainer_ARSL(cfg, mode="test")
          trainer.load_weights(cfg.weights, ARSL_eval=True)
      else:
          trainer = Trainer(cfg, mode="test")
          trainer.load_weights(cfg.weights)
      # get inference images
      images = get_test_images(FLAGS.infer_dir, FLAGS.infer_img)
  
      # inference
      if FLAGS.slice_infer:
          trainer.slice_predict(
              images,
              slice_size=FLAGS.slice_size,
              overlap_ratio=FLAGS.overlap_ratio,
              combine_method=FLAGS.combine_method,
              match_threshold=FLAGS.match_threshold,
              match_metric=FLAGS.match_metric,
              draw_threshold=FLAGS.draw_threshold,
              output_dir=FLAGS.output_dir,
              save_results=FLAGS.save_results,
              visualize=FLAGS.visualize,
          )
      else:
          trainer.predict(
              images,
              draw_threshold=FLAGS.draw_threshold,
              output_dir=FLAGS.output_dir,
              save_results=FLAGS.save_results,
              visualize=FLAGS.visualize,
          )
  
file_path: PaddleDetection/tools/infer.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import sys
  import warnings
  import glob
  import ast
  import paddle
  from ppdet.core.workspace import load_config, merge_config
  from ppdet.engine import Trainer, Trainer_ARSL
  from ppdet.utils.check import check_gpu, check_npu, check_xpu, check_mlu, check_version, check_config
  from ppdet.utils.cli import ArgsParser, merge_args
  from ppdet.slim import build_slim_model
  from ppdet.utils.logger import setup_logger
label_desc: Use image node_id 3 for calling a global function with example usage: run(FLAGS, cfg) without return types