code: def gen_json(args):
      """Format XML and transform json.
      generate train and val json, prepare for tracking dataloader"""
      js = {}
      VID_base_path = os.path.join(args.download_dir, "./ILSVRC")
      ann_base_path = os.path.join(
          VID_base_path, "Annotations/DET/train/"
      )
      sub_sets = ("a", "b", "c", "d", "e", "f", "g", "h", "i")
      for sub_set in sub_sets:
          sub_set_base_path = os.path.join(ann_base_path, sub_set)
          if "a" == sub_set:
              xmls = sorted(
                  glob.glob(
                      os.path.join(sub_set_base_path, "*", "*.xml")
                  )
              )
          else:
              xmls = sorted(
                  glob.glob(os.path.join(sub_set_base_path, "*.xml"))
              )
          n_imgs = len(xmls)
          for f, xml in enumerate(xmls):
              print(
                  "subset: {} frame id: {:08d} / {:08d}".format(
                      sub_set, f, n_imgs
                  )
              )
              xmltree = ET.parse(xml)
              objects = xmltree.findall("object")
  
              video = os.path.join(
                  sub_set, xml.split("/")[-1].split(".")[0]
              )
  
              for id, object_iter in enumerate(objects):
                  bndbox = object_iter.find("bndbox")
                  bbox = [
                      int(bndbox.find("xmin").text),
                      int(bndbox.find("ymin").text),
                      int(bndbox.find("xmax").text),
                      int(bndbox.find("ymax").text),
                  ]
                  frame = "%06d" % (0)
                  obj = "%02d" % (id)
                  if video not in js:
                      js[video] = {}
                  if obj not in js[video]:
                      js[video][obj] = {}
                  js[video][obj][frame] = bbox
  
      train = {k: v for (k, v) in js.items() if "i/" not in k}
      val = {k: v for (k, v) in js.items() if "i/" in k}
      json.dump(
          train,
          open(os.path.join(args.download_dir, "train.json"), "w"),
          indent=4,
          sort_keys=True,
      )
      json.dump(
          val,
          open(os.path.join(args.download_dir, "val.json"), "w"),
          indent=4,
          sort_keys=True,
      )
  
file_path: gluon-cv/scripts/datasets/ilsvrc_det.py
imports: import argparse
  import tarfile
  import os
  import glob
  import json
  import time
  from concurrent import futures
  import numpy
  from gluoncv.utils.filesystem import try_import_cv2
  from gluoncv.utils import download, makedirs
  from gluoncv.utils.data.tracking import crop_like_SiamFC, printProgress
label_desc: Use image node_id 5 for calling a global function with example usage: gen_json(args) without return types