code: def main():
      args = parse_args()
  
      # register all modules in mmdet into the registries
      register_all_modules()
  
      # build the model from a config file and a checkpoint file
      model = init_detector(
          args.config, args.checkpoint, device=args.device
      )
  
      if not os.path.exists(args.out_dir) and not args.show:
          os.mkdir(args.out_dir)
  
      # init visualizer
      visualizer = VISUALIZERS.build(model.cfg.visualizer)
      visualizer.dataset_meta = model.dataset_meta
  
      # get file list
      files, source_type = get_file_list(args.img)
      from detic.utils import (
          get_class_names,
          get_text_embeddings,
          reset_cls_layer_weight,
      )
  
      # class name embeddings
      if args.class_name:
          dataset_classes = args.class_name
      elif args.dataset:
          dataset_classes = get_class_names(args.dataset)
      embedding = get_text_embeddings(
          dataset=args.dataset, custom_vocabulary=args.class_name
      )
      visualizer.dataset_meta["classes"] = dataset_classes
      reset_cls_layer_weight(model, embedding)
  
      # start detector inference
      progress_bar = ProgressBar(len(files))
      for file in files:
          result = inference_detector(model, file)
  
          img = mmcv.imread(file)
          img = mmcv.imconvert(img, "bgr", "rgb")
  
          if source_type["is_dir"]:
              filename = os.path.relpath(file, args.img).replace(
                  "/", "_"
              )
          else:
              filename = os.path.basename(file)
          out_file = (
              None
              if args.show
              else os.path.join(args.out_dir, filename)
          )
  
          progress_bar.update()
  
          visualizer.add_datasample(
              filename,
              img,
              data_sample=result,
              draw_gt=False,
              show=args.show,
              wait_time=0,
              out_file=out_file,
              pred_score_thr=args.score_thr,
          )
  
      if not args.show:
          print_log(
              f"\nResults have been saved at {os.path.abspath(args.out_dir)}"
          )
  
file_path: mmdetection/projects/Detic/demo.py
imports: import os
  import urllib
  from argparse import ArgumentParser
  import mmcv
  import torch
  from mmengine.logging import print_log
  from mmengine.utils import ProgressBar, scandir
  from mmdet.apis import inference_detector, init_detector
  from mmdet.registry import VISUALIZERS
  from mmdet.utils import register_all_modules
label_desc: Use image node_id 3 for calling a global function with example usage: main() without return types