vision icon indicating copy to clipboard operation
vision copied to clipboard

[Feature Request] Support same_on_batch option for transforms

Open xvjiarui opened this issue 5 years ago • 5 comments

🚀 Feature

In the latest torchvison, transforms support tensor input (very nice feature, cheers!).

Motivation

As titled, same_on_batch option is not available for torchvision transforms. For example, RandomResizedCrop will crop at the same location for all images in the batch (which is ideal for video, but not for batched images).

Pitch

Kornia has this feature off the shelf. Maybe torchvision could follow the same API.

cc @vfdev-5

xvjiarui avatar Oct 28 '20 21:10 xvjiarui

@xvjiarui thanks for the feature request ! Yes, we are also thinking about applying random transformations on each image in the batch.

vfdev-5 avatar Oct 28 '20 21:10 vfdev-5

Hi,

Thanks for opening this issue, this is indeed something we should plan to do at some point in the future.

But I think it might take some time before we get into it, because I think for a full-fleshed experience this will require torch.vmap and NestedTensor, both of which are currently prototypes in PyTorch.

I think we should be in close touch with @cpuhrsch (who is working on NestedTensor) and @zou3519 (who is working on vmap) so that we can beta-test those features in the context of this feature request. But I wouldn't expect this feature to be included in torchvision in the next 6 months.

fmassa avatar Oct 30 '20 09:10 fmassa

This never materialized, right?

mizoru avatar Nov 22 '22 18:11 mizoru

Any updates here? I think this would be super important

AlessandroMondin00 avatar Nov 07 '23 10:11 AlessandroMondin00

Hi,

I developed a library based on Torchvision v2 called Torchaug that aims to have batched transforms with random parameters for each sample in the batch.

For example RandomResizedCrop can be batched to handle different transforms.

I believe that as soon as vmap and nested tensors will be truly released by Pytorch, Torchvision will implement a more efficient way of doing it but this should work in the meantime :).

juliendenize avatar Mar 12 '24 13:03 juliendenize