code: def voc_xmls_to_cocojson(
      annotation_paths, label2id, output_dir, output_file
  ):
      output_json_dict = {
          "images": [],
          "type": "instances",
          "annotations": [],
          "categories": [],
      }
      bnd_id = 1  # bounding box start id
      im_id = 0
      print("Start converting !")
      for a_path in tqdm(annotation_paths):
          # Read annotation xml
          ann_tree = ET.parse(a_path)
          ann_root = ann_tree.getroot()
  
          img_info = voc_get_image_info(ann_root, im_id)
          output_json_dict["images"].append(img_info)
  
          for obj in ann_root.findall("object"):
              ann = voc_get_coco_annotation(obj=obj, label2id=label2id)
              ann.update({"image_id": im_id, "id": bnd_id})
              output_json_dict["annotations"].append(ann)
              bnd_id = bnd_id + 1
          im_id += 1
  
      for label, label_id in label2id.items():
          category_info = {
              "supercategory": "none",
              "id": label_id,
              "name": label,
          }
          output_json_dict["categories"].append(category_info)
      output_file = os.path.join(output_dir, output_file)
      with open(output_file, "w") as f:
          output_json = json.dumps(output_json_dict)
          f.write(output_json)
  
imports: import argparse
  import glob
  import json
  import os
  import os.path
  import shutil
  import xml.etree.ElementTree
  import numpy
  import PIL.ImageDraw
  from tqdm import tqdm
  import cv2
label_desc: Use image node_id 11 for calling a global function with example usage: voc_xmls_to_cocojson(annotation_paths, label2id, output_dir, output_file) without return types