pipelines/common_utils/lungmap_dataset.py
def load_mask(self, image_id, with_bb=False):
        """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]
        info = self.image_info[image_id]
        mask = np.zeros([info["height"], info["width"], len(info["polygons"])],
                        dtype=np.uint8)
        class_ids = []
        b_boxes = []
        for i, p in enumerate(info["polygons"]):
            # Get indexes of pixels inside the polygon and set them to 1
            y = p['points'][:, 1]
            x = p['points'][:, 0]
            rr, cc = skimage.draw.polygon(y, x)
            mask[rr, cc, i] = 1
            y1, y2, x1, x2 = self.bbox2(mask[:, :, i])
            b_boxes.append([y1, x1, y2, x2])
            my_id = [x['id'] for x in self.class_info if p['label'] == x['name']][0]
            class_ids.append(my_id)
        try:
            bboxes = np.vstack(b_boxes)
        except ValueError as e:
            print(len(b_boxes))

        # Return mask, and array of class IDs of each instance. Since we have
        # one class ID only, we return an array of 1s
        if with_bb:
            return mask, np.array(class_ids, dtype=np.int32), bboxes
        else:
            return mask, np.array(class_ids, 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, with_bb=False):
        info = self.image_info[image_id]
        mask = np.zeros([info["height"], info["width"], len(info["polygons"])],
                        dtype=np.uint8)
        class_ids = []
        b_boxes = []
        for i, p in enumerate(info["polygons"]):
            y = p['points'][:, 1]
            x = p['points'][:, 0]
            rr, cc = skimage.draw.polygon(y, x)
            mask[rr, cc, i] = 1
            y1, y2, x1, x2 = self.bbox2(mask[:, :, i])
            b_boxes.append([y1, x1, y2, x2])
            my_id = [x['id'] for x in self.class_info if p['label'] == x['name']][0]
            class_ids.append(my_id)
        try:
            bboxes = np.vstack(b_boxes)
        except ValueError as e:
            print(len(b_boxes))
        if with_bb:
            return mask, np.array(class_ids, dtype=np.int32), bboxes
        else:
            return mask, np.array(class_ids, dtype=np.int32)
def load_mask ( self , image_id , with_bb = False ) : info = self . image_info [ image_id ] mask = np . zeros ( [ info [ "height" ] , info [ "width" ] , len ( info [ "polygons" ] ) ] , dtype = np . uint8 ) class_ids = [ ] b_boxes = [ ] for i , p in enumerate ( info [ "polygons" ] ) : y = p [ 'points' ] [ : , 1 ] x = p [ 'points' ] [ : , 0 ] rr , cc = skimage . draw . polygon ( y , x ) mask [ rr , cc , i ] = 1 y1 , y2 , x1 , x2 = self . bbox2 ( mask [ : , : , i ] ) b_boxes . append ( [ y1 , x1 , y2 , x2 ] ) my_id = [ x [ 'id' ] for x in self . class_info if p [ 'label' ] == x [ 'name' ] ] [ 0 ] class_ids . append ( my_id ) try : bboxes = np . vstack ( b_boxes ) except ValueError as e : print ( len ( b_boxes ) ) if with_bb : return mask , np . array ( class_ids , dtype = np . int32 ) , bboxes else : return mask , np . array ( class_ids , 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
with_bb