Fix core tests with Pillow>=10.3.0 (#3034)

This commit is contained in:
J.Y authored and GitHub committed 2024-04-02 09:30:14 -07:00
1 parent 59d6acf9da
commit a990721fa8
3 files changed
+4 -4

No files matched your search

+2 -2
View File
@@ -30,7 +30,7 @@ def get_image_mask_tensor_from_path(filepath: Path, scale_factor: float = 1.0) -
if scale_factor != 1.0:
width, height = pil_mask.size
newsize = (int(width * scale_factor), int(height * scale_factor))
pil_mask = pil_mask.resize(newsize, resample=Image.NEAREST)
pil_mask = pil_mask.resize(newsize, resample=Image.Resampling.NEAREST)
mask_tensor = torch.from_numpy(np.array(pil_mask)).unsqueeze(-1).bool()
if len(mask_tensor.shape) != 3:
raise ValueError("The mask image should have 1 channel")
@@ -50,7 +50,7 @@ def get_semantics_and_mask_tensors_from_path(
if scale_factor != 1.0:
width, height = pil_image.size
newsize = (int(width * scale_factor), int(height * scale_factor))
pil_image = pil_image.resize(newsize, resample=Image.NEAREST)
pil_image = pil_image.resize(newsize, resample=Image.Resampling.NEAREST)
semantics = torch.from_numpy(np.array(pil_image, dtype="int64"))[..., None]
mask = torch.sum(semantics == mask_indices, dim=-1, keepdim=True) == 0
return semantics, mask