icevision icon indicating copy to clipboard operation
icevision copied to clipboard

wrong voc data fixation request (wrong background color)

Open joowon-dm-snu opened this issue 3 years ago • 3 comments

🚀 Feature

Is your feature request related to a problem? Please describe.

voc/SegmentationObject/2010_002305's background color should be changed to black.

# icevision/icevision/core/mask.py
class VocMaskFile(MaskFile):
    def __init__(self, filepath: Union[str, Path], drop_void: bool = True):
        super().__init__(filepath=filepath)
        self.drop_void = drop_void

    def to_mask(self, h, w) -> MaskArray:
        mask_arr = np.array(Image.open(self.filepath))
        obj_ids = np.unique(mask_arr)[1:] # ->  np.unique(mask_arr) = [1, 255] then obj_ids 
        masks = mask_arr == obj_ids[:, None, None]

        if self.drop_void:
            masks = masks[:-1, ...]

        return MaskArray(masks)

white background cause error because... - np.unique(mask_arr)[1:] => [1, 255] - [1, 255][1:] => [255] - self.drop_void make empty array

Describe the solution you'd like A clear and concise description of what you want to happen.

class VocMaskFile(MaskFile):
    ...
    def to_mask(self, h, w) -> MaskArray:
        mask_arr = np.array(Image.open(self.filepath))
        unique_ids = np.unique(mask_arr)
        obj_ids = unique_ids[1:] if unique_ids[0] == 0 else unique_ids
        masks = mask_arr == obj_ids[:, None, None]
        ...
  

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

joowon-dm-snu avatar Mar 03 '22 04:03 joowon-dm-snu

Thanks for opening this issue! Do you want to open a quick PR about this one? It looks an overlook on our side and a quick fix with your solution

FraPochetti avatar Mar 03 '22 07:03 FraPochetti

I can open PR this weekend. I'll open PR if its not late for you :) (same for #1073)

joowon-dm-snu avatar Mar 03 '22 08:03 joowon-dm-snu

totally fine! thanks a lot!

FraPochetti avatar Mar 03 '22 14:03 FraPochetti