Skip to content

Commit a8856b9

Browse files
committed
Add support for images with other than 3 channels
1 parent b733ad1 commit a8856b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchvision/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __call__(self, pic):
3434
else:
3535
# handle PIL Image
3636
img = torch.ByteTensor(torch.ByteStorage.from_buffer(pic.tobytes()))
37-
img = img.view(pic.size[1], pic.size[0], 3)
37+
img = img.view(pic.size[1], pic.size[0], len(pic.mode))
3838
# put it from HWC to CHW format
3939
# yikes, this transpose takes 80% of the loading time/CPU
4040
img = img.transpose(0, 1).transpose(0, 2).contiguous()

0 commit comments

Comments
 (0)