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

Batch support for torchvision.transforms.functional #2546

Closed
Shubhammawa opened this issue Aug 3, 2020 · 1 comment
Closed

Batch support for torchvision.transforms.functional #2546

Shubhammawa opened this issue Aug 3, 2020 · 1 comment

Comments

@Shubhammawa
Copy link

Support for a batch of images in torchvision.transforms.functional.

Currently the torchvision.transforms.functional transformations take only a single image as input. Sometimes after creating the dataloader, I need to transform the images during the training loop, but passing the batch of images to transforms.functional raises an error expecting a 2/3 dimensional input while it gets a 4-dimensional input. I am currently solving the issue by looping through the images in the batch but it would be nice if the transforms could handle a batch of images on their own.

@fmassa
Copy link
Member

fmassa commented Aug 3, 2020

Hi,

We are progressively adding support for tensors inputs in the transforms.functional, and with this it will have support for batch of images as well.

See

if img.ndim < 4:
img = img.unsqueeze(dim=0)
need_squeeze = True

which gets dispatched to from torchvision.transforms.functional.resize when the input is a tensor #2292

As such, I'm closing this as a duplicate of #1375

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

No branches or pull requests

2 participants