-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Closed
Description
img = torch.ByteTensor(torch.ByteStorage.from_buffer(pic.tobytes())) |
If the image's mode is
1
, image.tobytes
is called to convert image to bytes. However, this will return a Tensor object with element size 8x of the original image, and result in RuntimeError.
Traceback (most recent call last):
File "test.py", line 106, in <module>
(0.2156, 0.2111, 0.2125)),
File "test.py", line 80, in __init__
img, pk = pk_loader(f'{fpath}/{path}')
File "test.py", line 64, in pk_loader
m = ToTensor(data[channel])
File "/usr/lib/python3.6/site-packages/torchvision/transforms.py", line 58, in __call__
img = img.view(pic.size[1], pic.size[0], nchannel)
RuntimeError: invalid argument 2: size '[1461 x 512 x 1]' is invalid for input of with 93504 elements at /pytorch/torch/lib/TH/THStorage.c:41
amorgun and stc1995
Metadata
Metadata
Assignees
Labels
No labels