class_docstr: Evaluate AR for object proposals, AP for instance detection/segmentation, AP
  for keypoint detection outputs using COCO's metrics.
  See http://cocodataset.org/#detection-eval and
  http://cocodataset.org/#keypoints-eval to understand its metrics.
  
  In addition to COCO, this evaluator is able to support any bounding box detection,
  instance segmentation, or keypoint detection dataset.
class_docstr_tok: ["Evaluate","AR","for","object","proposals",",","AP","for","instance","detection\/segmentation",",","AP","for","keypoint","detection","outputs","using","COCO","'s","metrics",".","See","http",":","\/\/cocodataset.org\/","#","detection-eval","and","http",":","\/\/cocodataset.org\/","#","keypoints-eval","to","understand","its","metrics",".","In","addition","to","COCO",",","this","evaluator","is","able","to","support","any","bounding","box","detection",",","instance","segmentation",",","or","keypoint","detection","dataset","."]
docstr: Derive the desired score numbers from summarized COCOeval.
  
  Args:
      coco_eval (None or COCOEval): None represents no predictions from model.
      iou_type (str):
      class_names (None or list[str]): if provided, will use it to predict
          per-category AP.
  
  Returns:
      a dict of {metric name: score}
docstr_tok: ["Derive","the","desired","score","numbers","from","summarized","COCOeval",".","Args",":","coco_eval","(","None","or","COCOEval",")",":","None","represents","no","predictions","from","model",".","iou_type","(","str",")",":","class_names","(","None","or","list","[","str","]",")",":","if","provided",",","will","use","it","to","predict","per-category","AP",".","Returns",":","a","dict","of","{","metric","name",":","score","}"]
code: def _derive_coco_results(self, coco_eval, iou_type, class_names=None):
      """
      Derive the desired score numbers from summarized COCOeval.
  
      Args:
          coco_eval (None or COCOEval): None represents no predictions from model.
          iou_type (str):
          class_names (None or list[str]): if provided, will use it to predict
              per-category AP.
  
      Returns:
          a dict of {metric name: score}
      """
  
      metrics = {
          "bbox": ["AP", "AP50", "AP75", "APs", "APm", "APl"],
          "segm": ["AP", "AP50", "AP75", "APs", "APm", "APl"],
          "keypoints": ["AP", "AP50", "AP75", "APm", "APl"],
      }[iou_type]
  
      if coco_eval is None:
          self._logger.warning("No predictions from the model!")
          return {metric: float("nan") for metric in metrics}
  
      # the standard metrics
      results = {
          metric: float(
              coco_eval.stats[idx] * 100
              if coco_eval.stats[idx] >= 0
              else "nan"
          )
          for idx, metric in enumerate(metrics)
      }
      self._logger.info(
          "Evaluation results for {}: \n".format(iou_type)
          + pd.DataFrame(
              [results.values()], columns=results.keys()
          ).to_string(index=False)
      )
      if not np.isfinite(sum(results.values())):
          self._logger.info(
              "Some metrics cannot be computed and is shown as NaN."
          )
  
      if class_names is None or len(class_names) <= 1:
          return results
      # Compute per-category AP
      # from https://github.com/facebookresearch/Detectron/blob/a6a835f5b8208c45d0dce217ce9bbda915f44df7/detectron/datasets/json_dataset_evaluator.py#L222-L252 # noqa
      precisions = coco_eval.eval["precision"]
      # precision has dims (iou, recall, cls, area range, max dets)
      assert len(class_names) == precisions.shape[2]
  
      results_per_category = []
      for idx, name in enumerate(class_names):
          # area range index 0: all area ranges
          # max dets index -1: typically 100 per image
          precision = precisions[:, :, idx, 0, -1]
          precision = precision[precision > -1]
          ap = np.mean(precision) if precision.size else float("nan")
          results_per_category.append(
              ("{}".format(name), float(ap * 100))
          )
  
      table = pd.DataFrame(
          results_per_category, columns=("category", "ap")
      ).to_string(index=False)
      self._logger.info(
          "Per-category {} AP: \n".format(iou_type) + table
      )
  
      results.update(
          {"AP-" + name: ap for name, ap in results_per_category}
      )
      return results
  
imports: import contextlib
  import copy
  import io
  import itertools
  import json
  import logging
  import os
  import pickle
  from collections import OrderedDict
  import numpy
  import torch
  import pandas
  from ..None import comm
  from ...data.registry.catalog import MetadataCatalog
  from ...data.registry.mscoco import convert_to_coco_json
  from ...data.structures import Boxes, BoxMode, pairwise_iou
  from ...data.detection.detection_utils import try_import_pycocotools
label_desc: Use image node_id 8 for calling the COCOEvaluator obj's underlying member method code with example usage: obj._derive_coco_results(coco_eval, iou_type, class_names) and returns: results, unknown, results