class_docstr: Pascal VOC evaluation metric.
  
  Args:
      iou_thrs (float or List[float]): IoU threshold. Defaults to 0.5.
      scale_ranges (List[tuple], optional): Scale ranges for evaluating
          mAP. If not specified, all bounding boxes would be included in
          evaluation. Defaults to None.
      metric (str | list[str]): Metrics to be evaluated. Options are
          'mAP', 'recall'. If is list, the first setting in the list will
           be used to evaluate metric.
      proposal_nums (Sequence[int]): Proposal number used for evaluating
          recalls, such as recall@100, recall@1000.
          Default: (100, 300, 1000).
      eval_mode (str): 'area' or '11points', 'area' means calculating the
          area under precision-recall curve, '11points' means calculating
          the average precision of recalls at [0, 0.1, ..., 1].
          The PASCAL VOC2007 defaults to use '11points', while PASCAL
          VOC2012 defaults to use 'area'.
      collect_device (str): Device name used for collecting results from
          different ranks during distributed training. Must be 'cpu' or
          'gpu'. Defaults to 'cpu'.
      prefix (str, optional): The prefix that will be added in the metric
          names to disambiguate homonymous metrics of different evaluators.
          If prefix is not provided in the argument, self.default_prefix
          will be used instead. Defaults to None.
docstr: Compute the metrics from processed results.
  
  Args:
      results (list): The processed results of each batch.
  
  Returns:
      dict: The computed metrics. The keys are the names of the metrics,
      and the values are corresponding results.
docstr_tok: ["Compute","the","metrics","from","processed","results",".","Args",":","results","(","list",")",":","The","processed","results","of","each","batch",".","Returns",":","dict",":","The","computed","metrics",".","The","keys","are","the","names","of","the","metrics",",","and","the","values","are","corresponding","results","."]
code: def compute_metrics(self, results: list) -> dict:
      """Compute the metrics from processed results.
  
      Args:
          results (list): The processed results of each batch.
  
      Returns:
          dict: The computed metrics. The keys are the names of the metrics,
          and the values are corresponding results.
      """
      logger: MMLogger = MMLogger.get_current_instance()
      gts, preds = zip(*results)
      eval_results = OrderedDict()
      if self.metric == "mAP":
          assert isinstance(self.iou_thrs, list)
          dataset_type = self.dataset_meta.get("dataset_type")
          if dataset_type in ["VOC2007", "VOC2012"]:
              dataset_name = "voc"
              if (
                  dataset_type == "VOC2007"
                  and self.eval_mode != "11points"
              ):
                  warnings.warn(
                      "Pascal VOC2007 uses `11points` as default "
                      "evaluate mode, but you are using "
                      f"{self.eval_mode}."
                  )
              elif (
                  dataset_type == "VOC2012" and self.eval_mode != "area"
              ):
                  warnings.warn(
                      "Pascal VOC2012 uses `area` as default "
                      "evaluate mode, but you are using "
                      f"{self.eval_mode}."
                  )
          else:
              dataset_name = self.dataset_meta["classes"]
  
          mean_aps = []
          for iou_thr in self.iou_thrs:
              logger.info(f'\n{"-" * 15}iou_thr: {iou_thr}{"-" * 15}')
              # Follow the official implementation,
              # http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCdevkit_18-May-2011.tar
              # we should use the legacy coordinate system in mmdet 1.x,
              # which means w, h should be computed as 'x2 - x1 + 1` and
              # `y2 - y1 + 1`
              mean_ap, _ = eval_map(
                  preds,
                  gts,
                  scale_ranges=self.scale_ranges,
                  iou_thr=iou_thr,
                  dataset=dataset_name,
                  logger=logger,
                  eval_mode=self.eval_mode,
                  use_legacy_coordinate=True,
              )
              mean_aps.append(mean_ap)
              eval_results[f"AP{int(iou_thr * 100):02d}"] = round(
                  mean_ap, 3
              )
          eval_results["mAP"] = sum(mean_aps) / len(mean_aps)
          eval_results.move_to_end("mAP", last=False)
      elif self.metric == "recall":
          gt_bboxes = [gt["bboxes"] for gt in gts]
          pr_bboxes = [pred[0] for pred in preds]
          recalls = eval_recalls(
              gt_bboxes,
              pr_bboxes,
              self.proposal_nums,
              self.iou_thrs,
              logger=logger,
              use_legacy_coordinate=True,
          )
          for i, num in enumerate(self.proposal_nums):
              for j, iou_thr in enumerate(self.iou_thrs):
                  eval_results[f"recall@{num}@{iou_thr}"] = recalls[
                      i, j
                  ]
          if recalls.shape[1] > 1:
              ar = recalls.mean(axis=1)
              for i, num in enumerate(self.proposal_nums):
                  eval_results[f"AR@{num}"] = ar[i]
      return eval_results
  
file_path: mmdetection/mmdet/evaluation/metrics/voc_metric.py
imports: import copy
  import warnings
  from collections import OrderedDict
  from typing import List, Optional, Sequence, Union
  import numpy
  from mmengine.evaluator import BaseMetric
  from mmengine.logging import MMLogger
  from mmdet.registry import METRICS
  from ..functional import eval_map, eval_recalls
label_desc: Use image node_id 3 for calling the VOCMetric obj's underlying member method code with example usage: obj.compute_metrics(results) and returns: eval_results