class_docstr: Generate data from the COCO dataset.
  
  See https://github.com/cocodataset/cocoapi/tree/master/PythonAPI for more information.
class_docstr_tok: ["Generate","data","from","the","COCO","dataset",".","See","https",":","\/\/github.com\/cocodataset\/cocoapi\/tree\/master\/PythonAPI","for","more","information","."]
docstr: Load annotations for an image_index.
          
docstr_tok: ["Load","annotations","for","an","image_index","."]
code: def load_annotations(self, image_index):
      """Load annotations for an image_index."""
      # get ground truth annotations
      annotations_ids = self.coco.getAnnIds(
          imgIds=self.image_ids[image_index], iscrowd=False
      )
      annotations = {
          "labels": np.empty((0,)),
          "bboxes": np.empty((0, 4)),
      }
  
      # some images appear to miss annotations (like image with id 257034)
      if len(annotations_ids) == 0:
          return annotations
  
      # parse annotations
      coco_annotations = self.coco.loadAnns(annotations_ids)
      for idx, a in enumerate(coco_annotations):
          # some annotations have basically no width / height, skip them
          if a["bbox"][2] < 1 or a["bbox"][3] < 1:
              continue
  
          annotations["labels"] = np.concatenate(
              [
                  annotations["labels"],
                  [self.coco_label_to_label(a["category_id"])],
              ],
              axis=0,
          )
          annotations["bboxes"] = np.concatenate(
              [
                  annotations["bboxes"],
                  [
                      [
                          a["bbox"][0],
                          a["bbox"][1],
                          a["bbox"][0] + a["bbox"][2],
                          a["bbox"][1] + a["bbox"][3],
                      ]
                  ],
              ],
              axis=0,
          )
  
      return annotations
  
imports: from ..preprocessing.generator import Generator
  from ..utils.image import read_image_bgr
  import os
  import numpy
  from pycocotools.coco import COCO
label_desc: Use image node_id 15 for calling the CocoGenerator obj's underlying member method code with example usage: obj.load_annotations(image_index) and returns: annotations, annotations