(self, image_id)
return mask, class_ids.astype(np.int32)
Generate instance masks for shapes of the given image ID.
Generate instance masks for shapes of the given image ID.
Generate instance masks for shapes of the given image ID .
def load_mask(self, image_id):
        """Generate instance masks for shapes of the given image ID.
        """
        info = self.image_info[image_id]
        shapes = info['shapes']
        count = len(shapes)
        mask = np.zeros([info['height'], info['width'], count], dtype=np.uint8)
        for i, (shape, _, dims) in enumerate(info['shapes']):
            mask[:, :, i:i+1] = self.draw_shape(mask[:, :, i:i+1].copy(),
                                                shape, dims, 1)
        # Handle occlusions
        occlusion = np.logical_not(mask[:, :, -1]).astype(np.uint8)
        for i in range(count-2, -1, -1):
            mask[:, :, i] = mask[:, :, i] * occlusion
            occlusion = np.logical_and(occlusion, np.logical_not(mask[:, :, i]))
        # Map class names to class IDs.
        class_ids = np.array([self.class_names.index(s[0]) for s in shapes])
        return mask, class_ids.astype(np.int32)
def load_mask ( self , image_id ) : info = self . image_info [ image_id ] shapes = info [ 'shapes' ] count = len ( shapes ) mask = np . zeros ( [ info [ 'height' ] , info [ 'width' ] , count ] , dtype = np . uint8 ) for i , ( shape , _ , dims ) in enumerate ( info [ 'shapes' ] ) : mask [ : , : , i : i + 1 ] = self . draw_shape ( mask [ : , : , i : i + 1 ] . copy ( ) , shape , dims , 1 ) # Handle occlusions occlusion = np . logical_not ( mask [ : , : , - 1 ] ) . astype ( np . uint8 ) for i in range ( count - 2 , - 1 , - 1 ) : mask [ : , : , i ] = mask [ : , : , i ] * occlusion occlusion = np . logical_and ( occlusion , np . logical_not ( mask [ : , : , i ] ) ) # Map class names to class IDs. class_ids = np . array ( [ self . class_names . index ( s [ 0 ] ) for s in shapes ] ) return mask , class_ids . astype ( np . int32 )