Solved by ptrblck in post #2 
              
              
                Did you make sure the target tensor do represent the valid segmentation mask? 
Your current code is: 


class MyDataset(Dataset):
    def __init__(self, image_paths, mask_paths, train=True):
        self.image_paths = image_paths
        self.mask_paths = mask_paths
        
    def transforms(self,…