class_docstr: Refer to 'https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/evaluation/evalInstanceLevelSemanticLabeling.py'
  Calculate the matching results of each image, each class, each IoU, and then get the final
  matching results of each class and each IoU of dataset. Base on the matching results, the AP
  and mAP can be calculated.
  we need two vectors for each class and for each overlap
  The first vector (y_true) is binary and is 1, where the ground truth says true,
  and is 0 otherwise.
  The second vector (y_score) is float [0...1] and represents the confidence of
  the prediction.
  We represent the following cases as:
                                        | y_true |   y_score
    gt instance with matched prediction |    1   | confidence
    gt instance w/o  matched prediction |    1   |     0.0
           false positive prediction    |    0   | confidence
  The current implementation makes only sense for an overlap threshold >= 0.5,
  since only then, a single prediction can either be ignored or matched, but
  never both. Further, it can never match to two gt instances.
  For matching, we vary the overlap and do the following steps:
    1.) remove all predictions that satisfy the overlap criterion with an ignore region (either void or *group)
    2.) remove matches that do not satisfy the overlap
    3.) mark non-matched predictions as false positive
  In the processing, 0 represent the first class of 'thing'. So the label will less 1 than the dataset.
  
  Args:
      num_classes (int): The unique number of target classes. Exclude background class, labeled 0 usually.
      overlaps (float|list, optional): The threshold of IoU. Default: 0.5.
      thing_list (list|None, optional): Thing class, only calculate AP for the thing class. Default: None.
docstr: In this method, we create two dicts of list
  - pred_instances: contains all predictions and their associated gt
  - gtInstances:   contains all gt instances and their associated predictions
  
  Args:
      preds (list): Prediction of image.
      gts (list): Ground truth of image.
      ignore_mask (np.ndarray, optional): Ignore mask. Default: None.
  
  Return:
      dict: pred_instances, the type is dict(list(dict))), e.g. {0: [{'pred_id':0, 'label':0',
          'pixel_count':100, 'confidence': 0.9, 'void_intersection': 0,
          'matched_gt': [gt_instance0, gt_instance1, ...]}, ], 1: }
      dict: gt_instances,  the type is dict(list(dict))), e.g. {0: [{'inst_id':0, 'label':0',
          'pixel_count':100, 'mask': np.ndarray, 'matched_pred': [pred_instance0, pred_instance1, ...]}, ], 1: }
code: def get_instances(self, preds, gts, ignore_mask=None):
      """
      In this method, we create two dicts of list
      - pred_instances: contains all predictions and their associated gt
      - gtInstances:   contains all gt instances and their associated predictions
  
      Args:
          preds (list): Prediction of image.
          gts (list): Ground truth of image.
          ignore_mask (np.ndarray, optional): Ignore mask. Default: None.
  
      Return:
          dict: pred_instances, the type is dict(list(dict))), e.g. {0: [{'pred_id':0, 'label':0',
              'pixel_count':100, 'confidence': 0.9, 'void_intersection': 0,
              'matched_gt': [gt_instance0, gt_instance1, ...]}, ], 1: }
          dict: gt_instances,  the type is dict(list(dict))), e.g. {0: [{'inst_id':0, 'label':0',
              'pixel_count':100, 'mask': np.ndarray, 'matched_pred': [pred_instance0, pred_instance1, ...]}, ], 1: }
      """
  
      pred_instances = defaultdict(list)
      gt_instances = defaultdict(list)
  
      gt_inst_count = 0
      for gt in gts:
          label, mask = gt
          gt_instance = defaultdict(list)
          gt_instance["inst_id"] = gt_inst_count
          gt_instance["label"] = label
          gt_instance["pixel_count"] = np.count_nonzero(mask)
          gt_instance["mask"] = mask
          gt_instances[label].append(gt_instance)
          gt_inst_count += 1
  
      pred_inst_count = 0
      for pred in preds:
          label, conf, mask = pred
          pred_instance = defaultdict(list)
          pred_instance["label"] = label
          pred_instance["pred_id"] = pred_inst_count
          pred_instance["pixel_count"] = np.count_nonzero(mask)
          pred_instance["confidence"] = conf
          if ignore_mask is not None:
              pred_instance["void_intersection"] = np.count_nonzero(
                  np.logical_and(mask, ignore_mask)
              )
  
          # Loop through all ground truth instances with matching label
          matched_gt = []
          for gt_num, gt_instance in enumerate(gt_instances[label]):
              # print(gt_instances)
              intersection = np.count_nonzero(
                  np.logical_and(
                      mask, gt_instances[label][gt_num]["mask"]
                  )
              )
              if intersection > 0:
                  gt_copy = gt_instance.copy()
                  pred_copy = pred_instance.copy()
  
                  gt_copy["intersection"] = intersection
                  pred_copy["intersection"] = intersection
  
                  matched_gt.append(gt_copy)
                  gt_instances[label][gt_num]["matched_pred"].append(
                      pred_copy
                  )
  
          pred_instance["matched_gt"] = matched_gt
          pred_inst_count += 1
          pred_instances[label].append(pred_instance)
  
      return pred_instances, gt_instances
  
file_path: PaddleSeg/contrib/PanopticDeepLab/utils/evaluation/instance.py
imports: from collections import defaultdict, OrderedDict
  import numpy
label_desc: Use image node_id 6 for calling the InstanceEvaluator obj's underlying member method code with example usage: obj.get_instances(preds, gts, ignore_mask) and returns: pred_instances,  gt_instances