Hi, I would like to ask about image segmentation. I am currently working on multi-class segmentation. However, when I check the unique value of the mask using np.unique(mask)
, I get a value of 0-255 instead of the class index (0-34). This also happens when I am working on binary segmentation. Can anyone explain this, why this happens and what should I do to convert the 0-255 value to a class index. Thanks.
class CityScapesDataset(Dataset):
def __init__(self, dir_path:str, dir_array: List, transform=None):
self.dir_path = dir_path
self.images_mask_array = dir_array
self.transform = transform
def __len__(self):
return len(self.images_mask_array)
def __getitem__(self, idx):
image_mask = self.images_mask_array[idx]
image_mask_path = os.path.join(self.dir_path, image_mask)
image_mask_read = cv2.imread(image_mask_path, cv2.IMREAD_COLOR)
image_mask_read = cv2.cvtColor(image_mask_read, cv2.COLOR_BGR2RGB)
image = image_mask_read[:, :256, :]
image = np.transpose(image, (2, 0, 1))
mask = image_mask_read[:, 256:, :]
mask = np.transpose(mask, (2, 0, 1))
return image, mask