def roidb_reader(roidb, mode): im, im_scales, gt_boxes, gt_classes = data_utils.get_image_blob( roidb, mode) im_id = roidb['im_id'] is_crowd = roidb['is_crowd'] im_height = np.round(roidb['height'] * im_scales) im_width = np.round(roidb['width'] * im_scales) is_difficult = roidb['is_difficult'] im_info = np.array([im_height, im_width, im_scales], dtype=np.float32) if mode == 'val': return im, gt_boxes, gt_classes, is_crowd, im_info, im_id, is_difficult outs = (im, gt_boxes, gt_classes, is_crowd, im_info, im_id) return outs
def roidb_reader(roidb, mode): im, im_scales = data_utils.get_image_blob(roidb, mode) im_id = roidb['id'] im_height = np.round(roidb['height'] * im_scales) im_width = np.round(roidb['width'] * im_scales) im_info = np.array([im_height, im_width, im_scales], dtype=np.float32) if mode == 'val': return im, im_info, im_id gt_boxes = roidb['gt_boxes'].astype('float32') gt_classes = roidb['gt_classes'].astype('int32') is_crowd = roidb['is_crowd'].astype('int32') segms = roidb['segms'] outs = (im, gt_boxes, gt_classes, is_crowd, im_info, im_id) if cfg.MASK_ON: gt_masks = [] valid = True segms = roidb['segms'] assert len(segms) == is_crowd.shape[0] for i in range(len(roidb['segms'])): segm, iscrowd = segms[i], is_crowd[i] gt_segm = [] if iscrowd: gt_segm.append(np.asarray([[0, 0]])) else: for poly in segm: if len(poly) == 0: valid = False break one_poly = np.array(poly).reshape(-1, 2) gt_segm.append(one_poly) if (not valid) or len(gt_segm) == 0: break if len(gt_segm) != 0: gt_masks.append(gt_segm) outs = outs + (gt_masks, ) return outs