wrong voc data fixation request (wrong background color)
🚀 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.
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
I can open PR this weekend. I'll open PR if its not late for you :) (same for #1073)
totally fine! thanks a lot!