class_docstr: Main evaluator class.
class_docstr_tok: ["Main","evaluator","class","."]
docstr: Add a single inference example as COCO annotation for later evaluation.
  
  Labels should not include a background/padding class, but only valid object
  classes.
  
  Note that this method raises an exception if the `threshold` is too
  high and thus eliminates all detections.
  
  Args:
    bboxes: [num_objects, 4] array of bboxes in COCO format [x, y, w, h] in
      absolute image coorinates.
    scores: [num_objects, num_classes] array of scores (softmax outputs).
    img_id: scalar COCO image ID.
docstr_tok: ["Add","a","single","inference","example","as","COCO","annotation","for","later","evaluation",".","Labels","should","not","include","a","background\/padding","class",",","but","only","valid","object","classes",".","Note","that","this","method","raises","an","exception","if","the","`","threshold","`","is","too","high","and","thus","eliminates","all","detections",".","Args",":","bboxes",":","[","num_objects",",","4","]","array","of","bboxes","in","COCO","format","[","x",",","y",",","w",",","h","]","in","absolute","image","coorinates",".","scores",":","[","num_objects",",","num_classes","]","array","of","scores","(","softmax","outputs",")",".","img_id",":","scalar","COCO","image","ID","."]
code: def add_annotation(self, bboxes, scores, img_id):
      """Add a single inference example as COCO annotation for later evaluation.
  
      Labels should not include a background/padding class, but only valid object
      classes.
  
      Note that this method raises an exception if the `threshold` is too
      high and thus eliminates all detections.
  
      Args:
        bboxes: [num_objects, 4] array of bboxes in COCO format [x, y, w, h] in
          absolute image coorinates.
        scores: [num_objects, num_classes] array of scores (softmax outputs).
        img_id: scalar COCO image ID.
      """
  
      # Get the sorted bboxes, labels and scores (threshold is applied here):
      i_bboxes, i_labels, i_scores = self.extract_classifications(
          bboxes, scores
      )
  
      if not i_bboxes.size:
          raise ValueError("All objects were thresholded out.")
  
      # Iterate through the thresholded predictions and pack them in COCO format:
      for bbox, label, score in zip(i_bboxes, i_labels, i_scores):
          single_classification = {
              "image_id": img_id,
              "category_id": self.label_to_coco_id[label],
              "bbox": bbox.tolist(),
              "score": score,
          }
          self.annotations.append(single_classification)
          self.annotated_img_ids.append(img_id)
  
imports: import collections
  import contextlib
  import functools
  import io
  import json
  import os
  import tempfile
  from typing import Any, Dict, List, Optional, Set
  import zipfile
  from absl import logging
  import jax
  import numpy
  import PIL
  from pycocotools.coco import COCO
  from pycocotools.cocoeval import COCOeval
  from tensorflow.io import gfile
label_desc: Use image node_id 5 for calling the DetectionEvaluator obj's underlying member method code with example usage: obj.add_annotation(bboxes, scores, img_id) without return types