code: def main():
      args = parse_args()
      assert args.out.endswith(
          "json"
      ), "The output file name must be json suffix"
  
      # 1 load image list info
      img_infos = collect_image_infos(
          args.img_path, args.exclude_extensions
      )
  
      # 2 convert to coco format data
      classes = list_from_file(args.classes)
      coco_info = cvt_to_coco_json(img_infos, classes)
  
      # 3 dump
      save_dir = os.path.join(args.img_path, "..", "annotations")
      mkdir_or_exist(save_dir)
      save_path = os.path.join(save_dir, args.out)
      dump(coco_info, save_path)
      print(f"save json file: {save_path}")
  
file_path: mmdetection/tools/dataset_converters/images2coco.py
imports: import argparse
  import os
  from mmengine.fileio import dump, list_from_file
  from mmengine.utils import mkdir_or_exist, scandir, track_iter_progress
  from PIL import Image
label_desc: Use image node_id 4 for calling a global function with example usage: main() without return types