Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

torchvision.io.decode_image can not be used as document #8698

Open
malfet opened this issue Oct 25, 2024 · 1 comment
Open

torchvision.io.decode_image can not be used as document #8698

malfet opened this issue Oct 25, 2024 · 1 comment

Comments

@malfet
Copy link
Contributor

malfet commented Oct 25, 2024

🐛 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

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")

Versions

0.19.1

@NicolasHug
Copy link
Member

Hi @malfet ,

This is a new feature introduced in 0.20. Can you try to update torchvision and let me know if there's any issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants