Skip to content

Current limitation on transforms #3224

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
voldemortX opened this issue Jan 6, 2021 · 3 comments
Open

Current limitation on transforms #3224

voldemortX opened this issue Jan 6, 2021 · 3 comments

Comments

@voldemortX
Copy link
Contributor

voldemortX commented Jan 6, 2021

The torchvision transforms now have 2 backends (PIL and Tensor), here are some functional mismatch between them and some may-be-useful features that neither of them support. Details are listed in transforms.py and functional.py.

Supported by PIL but not Tensor:

  1. Fill value for pad and random crop.
  2. Tensor images do not support many modes due to lack of metadata (maybe not possible to address). For instance, the adjust_* functions and autoaugment related functions.
  3. Tensors only support 3 interpolation modes (bilinear, linear, nearest).
  4. Tensors only support transformations on RGB images

Crop with crop size larger than the original image. #3297 Solved by #3333

Supported by Tensor but not PIL:

  1. Normalize (probably of no use for PIL images).
  2. Erase.

Supported by neither:

  1. adjust_gamma() and adjust_hue() do not support images with transparency.
  2. Subpixel translations. Affine Transform: why is translate a list[int] when the code suggests it could be floating point? #3293

Not supported by torchscript (mostly not possible given the current jit support):

  1. single value inputs in Pad(fill), RandomCrop(padding), Resize(size), RandomResizedCrop(size).
  2. PIL and Tensor conversions.
  3. Compose, RandomOrder, RandomChoice.
  4. Lambda.

It is just a draft, let me know if I forget anything. cc @vfdev-5 @datumbox

@vadimkantorov
Copy link

vadimkantorov commented Mar 22, 2021

It would be good if Resize* ops allowed to specify interpolation backend and supported native PyTorch interpolate function (that could execute on GPU) - then could potentially execute on TorchScript

@voldemortX
Copy link
Contributor Author

voldemortX commented Mar 23, 2021

@vadimkantorov Hi! Do you mean tensor&pil by interpolation backends? Currently I think Resize* on tensor is based on interpolation in pytorch, which has limited modes.
But I think it could potentially execute on GPU or by torchscript?

@zshn25
Copy link
Contributor

zshn25 commented Jul 28, 2023

PR to make RandomOrder scriptable here

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

4 participants