code: def __init__(
      self,
      data_dir,
      split,
      year=DEFAULT_YEAR,
      use_supercategory=False,
      **kwargs,
  ):
      super(COCOReader, self).__init__(**kwargs)
      self._data_dir = data_dir
      self._split = split
      self._year = year
  
      try:
          if self._split == "train":
              tf.logging.debug(
                  "Loading annotation json (may take a while)."
              )
  
          annotations_json = json.load(
              tf.gfile.Open(self._get_annotations_path())
          )
      except tf.errors.NotFoundError:
          raise InvalidDataDirectory(
              "Could not find COCO annotations in path"
          )
  
      self._total_records = len(annotations_json["images"])
  
      category_to_name = {
          c["id"]: (
              c["supercategory"] if use_supercategory else c["name"]
          )
          for c in annotations_json["categories"]
      }
  
      self._total_classes = sorted(set(category_to_name.values()))
  
      self._image_to_bboxes = {}
      for annotation in annotations_json["annotations"]:
          image_id = annotation["image_id"]
          x, y, width, height = annotation["bbox"]
  
          # If the class is not in `classes`, it was filtered.
          try:
              annotation_class = self.classes.index(
                  category_to_name[annotation["category_id"]]
              )
          except ValueError:
              continue
  
          self._image_to_bboxes.setdefault(image_id, []).append(
              {
                  "xmin": x,
                  "ymin": y,
                  "xmax": x + width,
                  "ymax": y + height,
                  "label": annotation_class,
              }
          )
  
      self._image_to_details = {}
      for image in annotations_json["images"]:
          self._image_to_details[image["id"]] = {
              "file_name": image["file_name"],
              "width": image["width"],
              "height": image["height"],
          }
  
      del annotations_json
  
      self.yielded_records = 0
      self.errors = 0
  
file_path: luminoth/luminoth/tools/dataset/readers/object_detection/coco.py
imports: import json
  import os
  import tensorflow
  from luminoth.tools.dataset.readers import InvalidDataDirectory
  from luminoth.tools.dataset.readers.object_detection import ObjectDetectionReader
  from luminoth.utils.dataset import read_image
label_desc: Use image node_id 1 to create a new COCOReader object from inherited base classes: ObjectDetectionReader with example: obj = COCOReader(data_dir, split, year, use_supercategory)