vip.py
def load_mask(self, image_id):
        """Load instance masks for the given image.

        Different datasets use different ways to store masks. This
        function converts the different mask format to one format
        in the form of a bitmap [height, width, instances].

        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"] != "VIP":
            return super(VIPDataset, self).load_mask(image_id)

        class_ids = []
        instance_masks = []

        gt_inst_data = cv2.imread(image_info["inst_anno"], cv2.IMREAD_GRAYSCALE)
        # get all instance label list
        unique_inst = np.unique(gt_inst_data)
        background_ind = np.where(unique_inst == 0)[0]
        unique_inst = np.delete(unique_inst, background_ind)

        # print("unique_inst", unique_inst)

        for i in range(unique_inst.shape[0]):
            inst_mask = unique_inst[i]
            # get specific instance mask
            im_mask = (gt_inst_data == inst_mask)
            instance_masks.append(im_mask)
            class_ids.append(1)
        # Pack instance masks into an array
        if class_ids:
            mask = np.stack(instance_masks, axis=2)
            class_ids = np.array(class_ids, dtype=np.int32)
            return mask, class_ids
        else:
            # Call super class to return an empty mask
            return super(VIPDataset, self).load_mask(image_id)
Load instance masks for the given image.

        Different datasets use different ways to store masks. This
        function converts the different mask format to one format
        in the form of a bitmap [height, width, instances].

        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.
        
Load instance masks for the given image.
Different datasets use different ways to store masks. This
function converts the different mask format to one format
in the form of a bitmap [height, width, instances].
Load instance masks for the given image . Different datasets use different ways to store masks . This function converts the different mask format to one format in the form of a bitmap [ height width instances ] .
def load_mask(self, image_id):
        image_info = self.image_info[image_id]
        if image_info["source"] != "VIP":
            return super(VIPDataset, self).load_mask(image_id)
        class_ids = []
        instance_masks = []
        gt_inst_data = cv2.imread(image_info["inst_anno"], cv2.IMREAD_GRAYSCALE)
        unique_inst = np.unique(gt_inst_data)
        background_ind = np.where(unique_inst == 0)[0]
        unique_inst = np.delete(unique_inst, background_ind)
        for i in range(unique_inst.shape[0]):
            inst_mask = unique_inst[i]
            im_mask = (gt_inst_data == inst_mask)
            instance_masks.append(im_mask)
            class_ids.append(1)
        if class_ids:
            mask = np.stack(instance_masks, axis=2)
            class_ids = np.array(class_ids, dtype=np.int32)
            return mask, class_ids
        else:
            return super(VIPDataset, self).load_mask(image_id)
def load_mask ( self , image_id ) : image_info = self . image_info [ image_id ] if image_info [ "source" ] != "VIP" : return super ( VIPDataset , self ) . load_mask ( image_id ) class_ids = [ ] instance_masks = [ ] gt_inst_data = cv2 . imread ( image_info [ "inst_anno" ] , cv2 . IMREAD_GRAYSCALE ) unique_inst = np . unique ( gt_inst_data ) background_ind = np . where ( unique_inst == 0 ) [ 0 ] unique_inst = np . delete ( unique_inst , background_ind ) for i in range ( unique_inst . shape [ 0 ] ) : inst_mask = unique_inst [ i ] im_mask = ( gt_inst_data == inst_mask ) instance_masks . append ( im_mask ) class_ids . append ( 1 ) if class_ids : mask = np . stack ( instance_masks , axis = 2 ) class_ids = np . array ( class_ids , dtype = np . int32 ) return mask , class_ids else : return super ( VIPDataset , self ) . load_mask ( image_id )
Load instance masks for the given image.
Load instance masks for the given image .
"""Load instance masks for the given image.

        Different datasets use different ways to store masks. This
        function converts the different mask format to one format
        in the form of a bitmap [height, width, instances].

        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.
        """ # get all instance label list # print("unique_inst", unique_inst) # get specific instance mask # Pack instance masks into an array # Call super class to return an empty mask
None
self
image_id