x = Image.open(img_path)
y = Image.open(label_path)
x = np.array(x)
y = np.array(y)
if self.transform is not None:
out = self.transform(image=x, mask=y)
x = out["image"]
After Change
ind: int) -> Tuple[torch.FloatTensor, torch.LongTensor]:
img_path = self.img_paths[ind]
label_path = self.label_paths[ind]
x = self.img_load_fn(img_path)
y = self.label_load_fn(label_path)
if x.ndim == 2:
// (h, w) --> (h, w, 1)
x = x[..., np.newaxis]
if self.transform is not None:
out = self.transform(image=x, mask=y)
x = out["image"]
y = out["mask"]
x = torch.from_numpy(x).permute(2, 0, 1).float()
y = torch.from_numpy(y).long()
return (x, y)