code: def run(FLAGS, cfg):
      if FLAGS.json_eval:
          logger.info(
              "In json_eval mode, PaddleDetection will evaluate json files in "
              "output_eval directly. And proposal.json, bbox.json and mask.json "
              "will be detected by default."
          )
          json_eval_results(
              cfg.metric,
              json_directory=FLAGS.output_eval,
              dataset=create("EvalDataset")(),
          )
          return
  
      # init parallel environment if nranks > 1
      init_parallel_env()
      ssod_method = cfg.get("ssod_method", None)
      if ssod_method == "ARSL":
          # build ARSL_trainer
          trainer = Trainer_ARSL(cfg, mode="eval")
          # load ARSL_weights
          trainer.load_weights(cfg.weights, ARSL_eval=True)
      else:
          # build trainer
          trainer = Trainer(cfg, mode="eval")
          # load weights
          trainer.load_weights(cfg.weights)
  
      # training
      if FLAGS.slice_infer:
          trainer.evaluate_slice(
              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,
          )
      else:
          trainer.evaluate()
  
file_path: PaddleDetection/tools/eval.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import sys
  import warnings
  import paddle
  from ppdet.core.workspace import create, load_config, merge_config
  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.engine import Trainer, Trainer_ARSL, init_parallel_env
  from ppdet.metrics.coco_utils import json_eval_results
  from ppdet.slim import build_slim_model
  from ppdet.utils.logger import setup_logger
label_desc: Use image node_id 2 for calling a global function with example usage: run(FLAGS, cfg) without return types