class_docstr: Object Detection Inferencer.
  
  Args:
      model (str, optional): Path to the config file or the model name
          defined in metafile. For example, it could be
          "rtmdet-s" or 'rtmdet_s_8xb32-300e_coco' or
          "configs/rtmdet/rtmdet_s_8xb32-300e_coco.py".
          If model is not specified, user must provide the
          `weights` saved by MMEngine which contains the config string.
          Defaults to None.
      weights (str, optional): Path to the checkpoint. If it is not specified
          and model is a model name of metafile, the weights will be loaded
          from metafile. Defaults to None.
      device (str, optional): Device to run inference. If None, the available
          device will be automatically used. Defaults to None.
      scope (str, optional): The scope of the model. Defaults to mmdet.
      palette (str): Color palette used for visualization. The order of
          priority is palette -> config -> checkpoint. Defaults to 'none'.
      show_progress (bool): Control whether to display the progress
          bar during the inference process. Defaults to True.
docstr: Visualize predictions.
  
  Args:
      inputs (List[Union[str, np.ndarray]]): Inputs for the inferencer.
      preds (List[:obj:`DetDataSample`]): Predictions of the model.
      return_vis (bool): Whether to return the visualization result.
          Defaults to False.
      show (bool): Whether to display the image in a popup window.
          Defaults to False.
      wait_time (float): The interval of show (s). Defaults to 0.
      draw_pred (bool): Whether to draw predicted bounding boxes.
          Defaults to True.
      pred_score_thr (float): Minimum score of bboxes to draw.
          Defaults to 0.3.
      no_save_vis (bool): Whether to force not to save prediction
          vis results. Defaults to False.
      img_out_dir (str): Output directory of visualization results.
          If left as empty, no file will be saved. Defaults to ''.
  
  Returns:
      List[np.ndarray] or None: Returns visualization results only if
      applicable.
docstr_tok: ["Visualize","predictions",".","Args",":","inputs","(","List","[","Union","[","str",",","np.ndarray","]","]",")",":","Inputs","for","the","inferencer",".","preds","(","List","[",":","obj",":","`","DetDataSample","`","]",")",":","Predictions","of","the","model",".","return_vis","(","bool",")",":","Whether","to","return","the","visualization","result",".","Defaults","to","False",".","show","(","bool",")",":","Whether","to","display","the","image","in","a","popup","window",".","Defaults","to","False",".","wait_time","(","float",")",":","The","interval","of","show","(","s",")",".","Defaults","to","0.","draw_pred","(","bool",")",":","Whether","to","draw","predicted","bounding","boxes",".","Defaults","to","True",".","pred_score_thr","(","float",")",":","Minimum","score","of","bboxes","to","draw",".","Defaults","to","0.3.","no_save_vis","(","bool",")",":","Whether","to","force","not","to","save","prediction","vis","results",".","Defaults","to","False",".","img_out_dir","(","str",")",":","Output","directory","of","visualization","results",".","If","left","as","empty",",","no","file","will","be","saved",".","Defaults","to","``",".","Returns",":","List","[","np.ndarray","]","or","None",":","Returns","visualization","results","only","if","applicable","."]
code: def visualize(
      self,
      inputs: InputsType,
      preds: PredType,
      return_vis: bool = False,
      show: bool = False,
      wait_time: int = 0,
      draw_pred: bool = True,
      pred_score_thr: float = 0.3,
      no_save_vis: bool = False,
      img_out_dir: str = "",
      **kwargs,
  ) -> Union[List[np.ndarray], None]:
      """Visualize predictions.
  
      Args:
          inputs (List[Union[str, np.ndarray]]): Inputs for the inferencer.
          preds (List[:obj:`DetDataSample`]): Predictions of the model.
          return_vis (bool): Whether to return the visualization result.
              Defaults to False.
          show (bool): Whether to display the image in a popup window.
              Defaults to False.
          wait_time (float): The interval of show (s). Defaults to 0.
          draw_pred (bool): Whether to draw predicted bounding boxes.
              Defaults to True.
          pred_score_thr (float): Minimum score of bboxes to draw.
              Defaults to 0.3.
          no_save_vis (bool): Whether to force not to save prediction
              vis results. Defaults to False.
          img_out_dir (str): Output directory of visualization results.
              If left as empty, no file will be saved. Defaults to ''.
  
      Returns:
          List[np.ndarray] or None: Returns visualization results only if
          applicable.
      """
      if no_save_vis is True:
          img_out_dir = ""
  
      if not show and img_out_dir == "" and not return_vis:
          return None
  
      if self.visualizer is None:
          raise ValueError(
              'Visualization needs the "visualizer" term'
              "defined in the config, but got None."
          )
  
      results = []
  
      for single_input, pred in zip(inputs, preds):
          if isinstance(single_input, str):
              img_bytes = mmengine.fileio.get(single_input)
              img = mmcv.imfrombytes(img_bytes)
              img = img[:, :, ::-1]
              img_name = osp.basename(single_input)
          elif isinstance(single_input, np.ndarray):
              img = single_input.copy()
              img_num = str(self.num_visualized_imgs).zfill(8)
              img_name = f"{img_num}.jpg"
          else:
              raise ValueError(
                  "Unsupported input type: " f"{type(single_input)}"
              )
  
          out_file = (
              osp.join(img_out_dir, "vis", img_name)
              if img_out_dir != ""
              else None
          )
  
          self.visualizer.add_datasample(
              img_name,
              img,
              pred,
              show=show,
              wait_time=wait_time,
              draw_gt=False,
              draw_pred=draw_pred,
              pred_score_thr=pred_score_thr,
              out_file=out_file,
          )
          results.append(self.visualizer.get_image())
          self.num_visualized_imgs += 1
  
      return results
  
imports: import copy
  import os.path
  import warnings
  from typing import Dict, Iterable, List, Optional, Sequence, Tuple, Union
  import mmcv
  import mmengine
  import numpy
  import torch.nn
  from mmcv.transforms import LoadImageFromFile
  from mmengine.dataset import Compose
  from mmengine.fileio import get_file_backend, isdir, join_path, list_dir_or_file
  from mmengine.infer.infer import BaseInferencer, ModelType
  from mmengine.model.utils import revert_sync_batchnorm
  from mmengine.registry import init_default_scope
  from mmengine.runner.checkpoint import _load_checkpoint_to_model
  from mmengine.visualization import Visualizer
  from rich.progress import track
  from mmdet.evaluation import INSTANCE_OFFSET
  from mmdet.registry import DATASETS
  from mmdet.structures import DetDataSample
  from mmdet.structures.mask import encode_mask_results, mask2bbox
  from mmdet.utils import ConfigType
  from ..evaluation import get_classes
label_desc: Use image node_id 10 for calling the DetInferencer obj's underlying member method code with example usage: obj.visualize(inputs, preds, return_vis, show, wait_time, draw_pred, pred_score_thr, no_save_vis, img_out_dir) and returns: results, None