'Loads COCO bounding-box instance annotations. Crowd instances are
handled by marking their overlaps (with all categories) to -1. This
overlap value means that crowd "instances" are excluded from training.'

def _load_coco_annotation(self, index):

    im_ann = self._COCO.loadImgs(index)[0]
    width = im_ann['width']
    height = im_ann['height']
    annIds = self._COCO.getAnnIds(imgIds=index, iscrowd=None)
    objs = self._COCO.loadAnns(annIds)
    valid_objs = []
    for obj in objs:
        x1 = np.max((0, obj['bbox'][0]))
        y1 = np.max((0, obj['bbox'][1]))
        x2 = np.min(((width - 1), (x1 + np.max((0, (obj['bbox'][2] - 1))))))
        y2 = np.min(((height - 1), (y1 + np.max((0, (obj['bbox'][3] - 1))))))
        if ((obj['area'] > 0) and (x2 >= x1) and (y2 >= y1)):
            obj['clean_bbox'] = [x1, y1, x2, y2]
            valid_objs.append(obj)
    objs = valid_objs
    num_objs = len(objs)
    boxes = np.zeros((num_objs, 4), dtype=np.uint16)
    gt_classes = np.zeros(num_objs, dtype=np.int32)
    overlaps = np.zeros((num_objs, self.num_classes), dtype=np.float32)
    seg_areas = np.zeros(num_objs, dtype=np.float32)
    coco_cat_id_to_class_ind = dict([(self._class_to_coco_cat_id[cls], self._class_to_ind[cls]) for cls in self._classes[1:]])
    for (ix, obj) in enumerate(objs):
        cls = coco_cat_id_to_class_ind[obj['category_id']]
        boxes[ix, :] = obj['clean_bbox']
        gt_classes[ix] = cls
        seg_areas[ix] = obj['area']
        if obj['iscrowd']:
            overlaps[ix, :] = (-1.0)
        else:
            overlaps[(ix, cls)] = 1.0
    ds_utils.validate_boxes(boxes, width=width, height=height)
    overlaps = scipy.sparse.csr_matrix(overlaps)
    return {'boxes': boxes, 'gt_classes': gt_classes, 'gt_overlaps': overlaps, 'flipped': False, 'seg_areas': seg_areas}
