code: def instances2dict(
      image_list: list, args: CArgs, backend_args: Optional[dict] = None
  ) -> dict:
      """A wrapper of obj:``cityscapesscripts.evaluation.
  
      evalInstanceLevelSemanticLabeling.instances2dict``. Support loading
      groundtruth image from file backend.
      Args:
          image_list (list): A list of image file.
          args (CArgs): A global object setting in
              obj:``cityscapesscripts.evaluation.
              evalInstanceLevelSemanticLabeling``
          backend_args (dict, optional): Arguments to instantiate the
              preifx of uri corresponding backend. Defaults to None.
      Returns:
          dict: The processed groundtruth results.
      """
      if not HAS_CITYSCAPESAPI:
          raise RuntimeError(
              "Failed to import `cityscapesscripts`."
              "Please try to install official "
              "cityscapesscripts by "
              '"pip install cityscapesscripts"'
          )
      imgCount = 0
      instanceDict = {}
  
      if not isinstance(image_list, list):
          image_list = [image_list]
  
      if not args.quiet:
          print(f"Processing {len(image_list)} images...")
  
      for image_name in image_list:
          # Load image
          img_bytes = get(image_name, backend_args=backend_args)
          imgNp = mmcv.imfrombytes(
              img_bytes, flag="unchanged", backend="pillow"
          )
  
          # Initialize label categories
          instances: dict = {}
          for label in labels:
              instances[label.name] = []
  
          # Loop through all instance ids in instance image
          for instanceId in np.unique(imgNp):
              instanceObj = Instance(imgNp, instanceId)
  
              instances[id2label[instanceObj.labelID].name].append(
                  instanceObj.toDict()
              )
  
          instanceDict[image_name] = instances
          imgCount += 1
  
          if not args.quiet:
              print(f"\rImages Processed: {imgCount}", end=" ")
              sys.stdout.flush()
  
      return instanceDict
  
file_path: mmdetection/mmdet/evaluation/functional/cityscapes_utils.py
imports: import json
  import os
  import sys
  from pathlib import Path
  from typing import Optional, Union
  import mmcv
  import numpy
  from mmengine.fileio import get
label_desc: Use image node_id 6 for calling a global function with example usage: instances2dict(image_list, args, backend_args) and returns: instanceDict