vision icon indicating copy to clipboard operation
vision copied to clipboard

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

Open hyperkai opened this issue 8 months ago • 2 comments

🐛 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'

hyperkai avatar Apr 19 '25 05:04 hyperkai

Sure, happy to consider a PR @hyperkai .

NicolasHug avatar Apr 22 '25 11:04 NicolasHug

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

chengolivia avatar Jun 14 '25 19:06 chengolivia

Yes, feel free to submit a PR @chengolivia , thank you

NicolasHug avatar Jun 23 '25 10:06 NicolasHug