Add cropping options to data processing (#1236)

This commit is contained in:
Matthew Tancik authored and GitHub committed 2023-01-16 15:34:20 -08:00
1 parent bd1060ee83
commit 5b50740f45
5 files changed
+159 -3

No files matched your search

+2
View File
@@ -32,6 +32,8 @@ def get_image_mask_tensor_from_path(filepath: Path, scale_factor: float = 1.0) -
newsize = (int(width * scale_factor), int(height * scale_factor))
pil_mask = pil_mask.resize(newsize, resample=Image.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")
return mask_tensor