Skip to content

Setting a 1D tensor to ToImage() gets an empty error message #9025

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

Open
hyperkai opened this issue Apr 19, 2025 · 2 comments
Open

Setting a 1D tensor to ToImage() gets an empty error message #9025

hyperkai opened this issue Apr 19, 2025 · 2 comments

Comments

@hyperkai
Copy link

🐛 Describe the bug

Setting a 1D tensor to ToImage() gets the empty error message as shown below:

from torchvision.datasets import OxfordIIITPet
import torch

my_data = OxfordIIITPet(
    root="data"
)

ti = ToImage()

ti(torch.tensor([0])) # Error

ValueError:

So, it should be something like below:

ValueError: the tensor must be 2D or more D tensor

Versions

import torchvision

torchvision.__version__ # '0.20.1'
@NicolasHug
Copy link
Member

Sure, happy to consider a PR @hyperkai .

@chengolivia
Copy link

Hi all, I have a fix ready that adds the suggested error message. Should I go ahead and submit a PR?

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

3 participants