(self, index)
return {'filaname' : filaname,
                'boxes' : boxes,
                'shape' : (height, width),
                'gt_classes': gt_classes,
                'gt_iscrowd' : gt_iscrowd,
                'has_boxes': has_boxes}
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.
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.
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):
        """
        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.
        """
        im_ann = self._coco.loadImgs(index)[0]
        filaname = im_ann['file_name']
        width = im_ann['width']
        height = im_ann['height']

        annIds = self._coco.getAnnIds(imgIds=index, iscrowd=None)
        objs = self._coco.loadAnns(annIds)
        # Sanitize bboxes -- some are invalid
        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['iscrowd'] and (self._image_set == 'train2017' or self._image_set == 'val2017'):
                continue
            if obj['area'] > 0 and x2 >= x1 and y2 >= y1:
                #obj['clean_bbox'] = [x1, y1, x2, y2]
                obj['clean_bbox'] = [y1/height, x1/width, y2/height, x2/width]
                valid_objs.append(obj)
        objs = valid_objs
        num_objs = len(objs)
        has_boxes = 1
        if num_objs == 0:
            has_boxes = 0

        boxes = np.zeros((num_objs, 4), dtype=np.float32)
        gt_classes = np.zeros((num_objs), dtype=np.int32)
        gt_iscrowd = np.zeros((num_objs), dtype=np.int32)
        seg_areas = np.zeros((num_objs), dtype=np.float32)

        # Lookup table to map from COCO category ids to our internal class
        # indices
        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']:
                gt_iscrowd[ix] = 1

        self.validate_boxes(boxes, width=width, height=height)
        return {'filaname' : filaname,
                'boxes' : boxes,
                'shape' : (height, width),
                'gt_classes': gt_classes,
                'gt_iscrowd' : gt_iscrowd,
                'has_boxes': has_boxes}
def _load_coco_annotation ( self , index ) : im_ann = self . _coco . loadImgs ( index ) [ 0 ] filaname = im_ann [ 'file_name' ] width = im_ann [ 'width' ] height = im_ann [ 'height' ] annIds = self . _coco . getAnnIds ( imgIds = index , iscrowd = None ) objs = self . _coco . loadAnns ( annIds ) # Sanitize bboxes -- some are invalid 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 [ 'iscrowd' ] and ( self . _image_set == 'train2017' or self . _image_set == 'val2017' ) : continue if obj [ 'area' ] > 0 and x2 >= x1 and y2 >= y1 : #obj['clean_bbox'] = [x1, y1, x2, y2] obj [ 'clean_bbox' ] = [ y1 / height , x1 / width , y2 / height , x2 / width ] valid_objs . append ( obj ) objs = valid_objs num_objs = len ( objs ) has_boxes = 1 if num_objs == 0 : has_boxes = 0 boxes = np . zeros ( ( num_objs , 4 ) , dtype = np . float32 ) gt_classes = np . zeros ( ( num_objs ) , dtype = np . int32 ) gt_iscrowd = np . zeros ( ( num_objs ) , dtype = np . int32 ) seg_areas = np . zeros ( ( num_objs ) , dtype = np . float32 ) # Lookup table to map from COCO category ids to our internal class # indices 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' ] : gt_iscrowd [ ix ] = 1 self . validate_boxes ( boxes , width = width , height = height ) return { 'filaname' : filaname , 'boxes' : boxes , 'shape' : ( height , width ) , 'gt_classes' : gt_classes , 'gt_iscrowd' : gt_iscrowd , 'has_boxes' : has_boxes }