class_docstr: Metric of separated and occluded masks which presented in paper `A Tri-
  Layer Plugin to Improve Occluded Detection.
  
  <https://arxiv.org/abs/2210.10046>`_.
  
  Separated COCO and Occluded COCO are automatically generated subsets of
  COCO val dataset, collecting separated objects and partially occluded
  objects for a large variety of categories. In this way, we define
  occlusion into two major categories: separated and partially occluded.
  
  - Separation: target object segmentation mask is separated into distinct
    regions by the occluder.
  - Partial Occlusion: target object is partially occluded but the
    segmentation mask is connected.
  
  These two new scalable real-image datasets are to benchmark a model's
  capability to detect occluded objects of 80 common categories.
  
  Please cite the paper if you use this dataset:
  
  @article{zhan2022triocc,
      title={A Tri-Layer Plugin to Improve Occluded Detection},
      author={Zhan, Guanqi and Xie, Weidi and Zisserman, Andrew},
      journal={British Machine Vision Conference},
      year={2022}
  }
  
  Args:
      occluded_ann (str): Path to the occluded coco annotation file.
      separated_ann (str): Path to the separated coco annotation file.
      score_thr (float): Score threshold of the detection masks.
          Defaults to 0.3.
      iou_thr (float): IoU threshold for the recall calculation.
          Defaults to 0.75.
      metric (str | List[str]): Metrics to be evaluated. Valid metrics
          include 'bbox', 'segm', 'proposal', and 'proposal_fast'.
          Defaults to 'bbox'.
docstr: Compute the recall of occluded and separated masks.
  
  Args:
      results (list[tuple]): Testing results of the dataset.
  
  Returns:
      dict[str, float]: The recall of occluded and separated masks.
docstr_tok: ["Compute","the","recall","of","occluded","and","separated","masks",".","Args",":","results","(","list","[","tuple","]",")",":","Testing","results","of","the","dataset",".","Returns",":","dict","[","str",",","float","]",":","The","recall","of","occluded","and","separated","masks","."]
code: def evaluate_occluded_separated(self, results: List[tuple]) -> dict:
      """Compute the recall of occluded and separated masks.
  
      Args:
          results (list[tuple]): Testing results of the dataset.
  
      Returns:
          dict[str, float]: The recall of occluded and separated masks.
      """
      dict_det = {}
      print_log("processing detection results...")
      prog_bar = mmengine.ProgressBar(len(results))
      for i in range(len(results)):
          gt, dt = results[i]
          img_id = dt["img_id"]
          cur_img_name = self._coco_api.imgs[img_id]["file_name"]
          if cur_img_name not in dict_det.keys():
              dict_det[cur_img_name] = []
  
          for bbox, score, label, mask in zip(
              dt["bboxes"], dt["scores"], dt["labels"], dt["masks"]
          ):
              cur_binary_mask = coco_mask.decode(mask)
              dict_det[cur_img_name].append(
                  [
                      score,
                      self.dataset_meta["classes"][label],
                      cur_binary_mask,
                      bbox,
                  ]
              )
          dict_det[cur_img_name].sort(
              key=lambda x: (-x[0], x[3][0], x[3][1])
          )  # rank by confidence from high to low, avoid same confidence
          prog_bar.update()
      print_log("\ncomputing occluded mask recall...", logger="current")
      occluded_correct_num, occluded_recall = self.compute_recall(
          dict_det, gt_ann=self.occluded_ann, is_occ=True
      )
      print_log(
          f"\nCOCO occluded mask recall: {occluded_recall:.2f}%",
          logger="current",
      )
      print_log(
          f"COCO occluded mask success num: {occluded_correct_num}",
          logger="current",
      )
      print_log("computing separated mask recall...", logger="current")
      separated_correct_num, separated_recall = self.compute_recall(
          dict_det, gt_ann=self.separated_ann, is_occ=False
      )
      print_log(
          f"\nCOCO separated mask recall: {separated_recall:.2f}%",
          logger="current",
      )
      print_log(
          f"COCO separated mask success num: {separated_correct_num}",
          logger="current",
      )
      table_data = [
          ["mask type", "recall", "num correct"],
          ["occluded", f"{occluded_recall:.2f}%", occluded_correct_num],
          [
              "separated",
              f"{separated_recall:.2f}%",
              separated_correct_num,
          ],
      ]
      table = AsciiTable(table_data)
      print_log("\n" + table.table, logger="current")
      return dict(
          occluded_recall=occluded_recall,
          separated_recall=separated_recall,
      )
  
file_path: mmdetection/mmdet/evaluation/metrics/coco_occluded_metric.py
imports: from typing import Dict, List, Optional, Union
  import mmengine
  import numpy
  from mmengine.fileio import load
  from mmengine.logging import print_log
  from pycocotools import mask
  from terminaltables import AsciiTable
  from mmdet.registry import METRICS
  from .coco_metric import CocoMetric
label_desc: Use image node_id 3 for calling the CocoOccludedSeparatedMetric obj's underlying member method code with example usage: obj.evaluate_occluded_separated(results) and returns: dict