def fetch_masks(self): rles = [] for item in self.anns: try: rles.append(frPyObjects(item['segmentation'], self.origin_height, self.origin_width)[0]) except Exception: pass if rles == []: raise NoLabelException else: self.masks = decode(rles).astype(np.float) self.masks = resize_blob(self.masks, self.image.shape[:2]) if self.flipped: self.masks = self.masks[:, :, ::-1]
def fetch_masks(self): rles = [] cls = [] for item in self.anns: try: rles.append( frPyObjects(item['segmentation'], self.origin_height, self.origin_width)[0]) cls.append(self.cats_to_labels[item['category_id']]) except Exception as e: # ignore crowd # print 'ignore crowd', item['iscrowd'] pass self.cls = cls self.masks = decode(rles).astype(np.float) self.masks = resize_blob(self.masks, self.image.shape[:2]) if self.flipped: self.masks = self.masks[:, :, ::-1]