model/mrcnn/cemeteries_dataset.py
def load_mask(self, image_id):
        """Generate instance masks for an image.
       Returns:
        masks: A bool array of shape [height, width, instance count] with
            one mask per instance.
        class_ids: a 1D array of class IDs of the instance masks.
        """
        image_info = self.image_info[image_id]
        if image_info["source"] != "cemeteries":
            return super(self.__class__, self).load_mask(image_id)

        # Convert polygons to a bitmap mask of shape
        # [height, width, instance_count]
        info = self.image_info[image_id]
        mask_shape = wkt.loads(info['mask_shape'])

        if mask_shape.geom_type == 'Polygon':
            mask = np.zeros([info["height"], info["width"], 1],
                            dtype=np.uint8)
            # Get indexes of pixels inside the polygon and set them to 1
            x_coords = np.array(mask_shape.boundary.coords.xy[0]) - info['geolocation_rd'][0]
            x_coords = (x_coords - info['geolocation_offset'][0]) / info['resolution'] / info['scale']
            x_coords = x_coords + info['width'] / 2
            y_coords = np.array(mask_shape.boundary.coords.xy[1]) - info['geolocation_rd'][1]
            y_coords = (-y_coords + info['geolocation_offset'][1]) / info['resolution'] / info['scale']
            y_coords = y_coords + info['height'] / 2

            rr, cc = skimage.draw.polygon(y_coords, x_coords, mask.shape)
            mask[rr, cc, 0] = 1
        else:
            raise ValueError('Don\'t know how to handle geometries of type {} for record {}'.format(
                mask_shape.geom_type, info['path']))

        # Return mask, and array of class IDs of each instance. Since we have
        # one class ID only, we return an array of 1s

        return mask.astype(np.bool), np.ones([mask.shape[-1]], dtype=np.int32)
Generate instance masks for an image.
       Returns:
        masks: A bool array of shape [height, width, instance count] with
            one mask per instance.
        class_ids: a 1D array of class IDs of the instance masks.
        
Generate instance masks for an image.
Generate instance masks for an image .
def load_mask(self, image_id):
        image_info = self.image_info[image_id]
        if image_info["source"] != "cemeteries":
            return super(self.__class__, self).load_mask(image_id)
        info = self.image_info[image_id]
        mask_shape = wkt.loads(info['mask_shape'])
        if mask_shape.geom_type == 'Polygon':
            mask = np.zeros([info["height"], info["width"], 1],
                            dtype=np.uint8)
            x_coords = np.array(mask_shape.boundary.coords.xy[0]) - info['geolocation_rd'][0]
            x_coords = (x_coords - info['geolocation_offset'][0]) / info['resolution'] / info['scale']
            x_coords = x_coords + info['width'] / 2
            y_coords = np.array(mask_shape.boundary.coords.xy[1]) - info['geolocation_rd'][1]
            y_coords = (-y_coords + info['geolocation_offset'][1]) / info['resolution'] / info['scale']
            y_coords = y_coords + info['height'] / 2
            rr, cc = skimage.draw.polygon(y_coords, x_coords, mask.shape)
            mask[rr, cc, 0] = 1
        else:
            raise ValueError('Don\'t know how to handle geometries of type {} for record {}'.format(
                mask_shape.geom_type, info['path']))
        return mask.astype(np.bool), np.ones([mask.shape[-1]], dtype=np.int32)
def load_mask ( self , image_id ) : image_info = self . image_info [ image_id ] if image_info [ "source" ] != "cemeteries" : return super ( self . __class__ , self ) . load_mask ( image_id ) info = self . image_info [ image_id ] mask_shape = wkt . loads ( info [ 'mask_shape' ] ) if mask_shape . geom_type == 'Polygon' : mask = np . zeros ( [ info [ "height" ] , info [ "width" ] , 1 ] , dtype = np . uint8 ) x_coords = np . array ( mask_shape . boundary . coords . xy [ 0 ] ) - info [ 'geolocation_rd' ] [ 0 ] x_coords = ( x_coords - info [ 'geolocation_offset' ] [ 0 ] ) / info [ 'resolution' ] / info [ 'scale' ] x_coords = x_coords + info [ 'width' ] / 2 y_coords = np . array ( mask_shape . boundary . coords . xy [ 1 ] ) - info [ 'geolocation_rd' ] [ 1 ] y_coords = ( - y_coords + info [ 'geolocation_offset' ] [ 1 ] ) / info [ 'resolution' ] / info [ 'scale' ] y_coords = y_coords + info [ 'height' ] / 2 rr , cc = skimage . draw . polygon ( y_coords , x_coords , mask . shape ) mask [ rr , cc , 0 ] = 1 else : raise ValueError ( 'Don\'t know how to handle geometries of type {} for record {}' . format ( mask_shape . geom_type , info [ 'path' ] ) ) return mask . astype ( np . bool ) , np . ones ( [ mask . shape [ - 1 ] ] , dtype = np . int32 )
Generate instance masks for an image.
Generate instance masks for an image .
"""Generate instance masks for an image.
       Returns:
        masks: A bool array of shape [height, width, instance count] with
            one mask per instance.
        class_ids: a 1D array of class IDs of the instance masks.
        """ # Convert polygons to a bitmap mask of shape # [height, width, instance_count] # Get indexes of pixels inside the polygon and set them to 1 # Return mask, and array of class IDs of each instance. Since we have # one class ID only, we return an array of 1s
A bool array of shape [height, width, instance count] with
one mask per instance.
class_ids: a 1D array of class IDs of the instance masks.
A bool array of shape [ height width instance count ] with one mask per instance . class_ids : a 1D array of class IDs of the instance masks .
masks
self
image_id