class_docstr: Extends the COCO API to (optionally) support panoptic annotations.
class_docstr_tok: ["Extends","the","COCO","API","to","(","optionally",")","support","panoptic","annotations","."]
docstr: Reload GT annotations, optionally just a subset.
docstr_tok: ["Reload","GT","annotations",",","optionally","just","a","subset","."]
code: def reload_ground_truth(
      self, included_image_ids: Optional[List[int]] = None
  ):
      """Reload GT annotations, optionally just a subset."""
      self.dataset, self.anns, self.cats, self.imgs = {}, {}, {}, {}
      self.imgToAnns = collections.defaultdict(
          list
      )  # pylint: disable=invalid-name
      self.catToImgs = collections.defaultdict(
          list
      )  # pylint: disable=invalid-name
      if self.annotation_file is not None:
          dataset = _load_json(self.annotation_file)
          assert isinstance(
              dataset, dict
          ), "annotation file format {} not supported".format(
              type(dataset)
          )
  
          if "segments_info" in dataset["annotations"][0]:
              # Dataset is in panoptic format. Translate to standard format:
              dataset[
                  "annotations"
              ] = _panoptic_to_standard_annotations(
                  dataset["annotations"]
              )
  
          if "iscrowd" not in dataset["annotations"][0]:
              # Dataset is in LVIS format. Add missing 'iscrowd' field":
              for image_annotation in dataset["annotations"]:
                  image_annotation["iscrowd"] = 0
  
          # Subselect included image IDs:
          if included_image_ids is not None:
              included_image_ids = set(included_image_ids)
              logging.warn(
                  "Using only a subset of validation set: %s of %s images.",
                  len(included_image_ids),
                  len(dataset["images"]),
              )
              dataset["images"] = [
                  a
                  for a in dataset["images"]
                  if a["id"] in included_image_ids
              ]
              dataset["annotations"] = [
                  a
                  for a in dataset["annotations"]
                  if a["image_id"] in included_image_ids
              ]
  
          self.dataset = dataset
          self.createIndex()
  
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 2 for calling the UniversalCOCO obj's underlying member method code with example usage: obj.reload_ground_truth(included_image_ids) without return types