code: def cvt_to_coco_json(img_infos, classes):
      image_id = 0
      coco = dict()
      coco["images"] = []
      coco["type"] = "instance"
      coco["categories"] = []
      coco["annotations"] = []
      image_set = set()
  
      for category_id, name in enumerate(classes):
          category_item = dict()
          category_item["supercategory"] = str("none")
          category_item["id"] = int(category_id)
          category_item["name"] = str(name)
          coco["categories"].append(category_item)
  
      for img_dict in img_infos:
          file_name = img_dict["filename"]
          assert file_name not in image_set
          image_item = dict()
          image_item["id"] = int(image_id)
          image_item["file_name"] = str(file_name)
          image_item["height"] = int(img_dict["height"])
          image_item["width"] = int(img_dict["width"])
          coco["images"].append(image_item)
          image_set.add(file_name)
  
          image_id += 1
      return coco
  
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 3 for calling a global function with example usage: cvt_to_coco_json(img_infos, classes) and returns: coco