@ptrblck, Hi, I tried with this model
class CustomDataset(Dataset):
def init(self, image_paths, target_paths, transform):   # initial logic happens like transform
    self.image_paths = image_paths
    self.target_paths = target_paths
    self.transform = transforms.Compose([transforms.ToTensor()])

def __getitem__(self, index):

    image = Image.open(self.image_paths[index])
    mask = Image.open(self.target_paths[index])
    t_image = self.transform(image)
    t_mask = self.transform(mask)
    return t_image, t_mask

def __len__(self):  # return count of sample we have

    return len(self.image_paths) 

I have already tried with .convert(‘RGB’) with mask = Image.open(self.target_paths[index]). But, i could not solve this problem. could you let me know how can I solve this?