Unverified Commit 98f1a409 authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

Replace `getbands()` with `get_image_num_channels()` (#6941)

parent ffd5a567
...@@ -167,7 +167,7 @@ def to_tensor(pic) -> Tensor: ...@@ -167,7 +167,7 @@ def to_tensor(pic) -> Tensor:
if pic.mode == "1": if pic.mode == "1":
img = 255 * img img = 255 * img
img = img.view(pic.size[1], pic.size[0], len(pic.getbands())) img = img.view(pic.size[1], pic.size[0], F_pil.get_image_num_channels(pic))
# put it from HWC to CHW format # put it from HWC to CHW format
img = img.permute((2, 0, 1)).contiguous() img = img.permute((2, 0, 1)).contiguous()
if isinstance(img, torch.ByteTensor): if isinstance(img, torch.ByteTensor):
...@@ -205,7 +205,7 @@ def pil_to_tensor(pic: Any) -> Tensor: ...@@ -205,7 +205,7 @@ def pil_to_tensor(pic: Any) -> Tensor:
# handle PIL Image # handle PIL Image
img = torch.as_tensor(np.array(pic, copy=True)) img = torch.as_tensor(np.array(pic, copy=True))
img = img.view(pic.size[1], pic.size[0], len(pic.getbands())) img = img.view(pic.size[1], pic.size[0], F_pil.get_image_num_channels(pic))
# put it from HWC to CHW format # put it from HWC to CHW format
img = img.permute((2, 0, 1)) img = img.permute((2, 0, 1))
return img return img
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment