from torchvision.io import decode_image
decode_image("foo.png")
but it fails with
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nshulga/miniconda3/envs/py-311/lib/python3.11/site-packages/torchvision/io/image.py", line 269, in decode_image
output = torch.ops.image.decode_image(input, mode.value, apply_exif_orientation)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/nshulga/miniconda3/envs/py-311/lib/python3.11/site-packages/torch/_ops.py", line 1061, in __call__
return self_._op(*args, **(kwargs or {}))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: image::decode_image() Expected a value of type 'Tensor' for argument 'data' but instead found type 'str'.
Position: 0
Value: 'foo.png'
Declaration: image::decode_image(Tensor data, int mode, bool apply_exif_orientation=False) -> Tensor
Cast error details: Unable to cast foo.png to Tensor
But read_image works as expeted:
from torchvision.io import read_image
read_image("foo.png")
š Describe the bug
By looking at https://pytorch.org/vision/0.20/generated/torchvision.io.decode_image.html it feels like one should be able to do something like
but it fails with
But read_image works as expeted:
Versions
0.19.1