def __getitem__(self, index):
    img = Image.open(self.images[index]).convert('RGB')
    if (self.mode == 'test'):
        if (self.transform is not None):
            img = self.transform(img)
        return (img, os.path.basename(self.images[index]))
    mask = Image.open(self.masks[index])
    if (self.mode == 'train'):
        (img, mask) = self._sync_transform(img, mask)
    elif (self.mode == 'val'):
        (img, mask) = self._val_sync_transform(img, mask)
    else:
        assert (self.mode == 'testval')
        mask = self._mask_transform(mask)
    if (self.transform is not None):
        img = self.transform(img)
    if (self.target_transform is not None):
        mask = self.target_transform(mask)
    return (img, mask)
def __getitem__(self, index):
    img = Image.open(self.images[index]).convert('RGB')
    if (self.mode == 'test'):
        if (self.transform is not None):
            img = self.transform(img)
        return (img, os.path.basename(self.images[index]))
    mask = Image.open(self.masks[index])
    if (self.mode == 'train'):
        (img, mask) = self._sync_transform(img, mask)
    elif (self.mode == 'val'):
        (img, mask) = self._val_sync_transform(img, mask)
    else:
        assert (self.mode == 'testval')
        mask = self._mask_transform(mask)
    if (self.transform is not None):
        img = self.transform(img)
    if (self.target_transform is not None):
        mask = self.target_transform(mask)
    return (img, mask)