vision icon indicating copy to clipboard operation
vision copied to clipboard

RandomOrder transform now accepts torch.Tensor and works well with torch.seed

Open zshn25 opened this issue 1 year ago • 3 comments

Changed the RandomOrder transform to use torch.randperm and thus make it Scriptable

zshn25 avatar Jul 28 '23 13:07 zshn25

:link: Helpful Links

:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/7773

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

pytorch-bot[bot] avatar Jul 28 '23 13:07 pytorch-bot[bot]

This PR also lifts the restriction of RandomOrder to take only PIL.Image as input.

https://pytorch.org/vision/0.8/transforms.html#transforms-on-pil-image-only

zshn25 avatar Jul 31 '23 11:07 zshn25

JIT Scripting still doesn't work. Gives the following error RuntimeError: Expected integer literal for index, whilw JIT Scripting

It is due to https://github.com/pytorch/pytorch/issues/16123

But, other benefits of this PR:

  • Removes restriction of inputs of RandomChoice of PIL.Image to also include torch.Tensors
  • A step closer to make it JIT Scriptable
  • Replaces the usage of the random module to native torch, thereby working well with torch seed

zshn25 avatar Aug 01 '23 16:08 zshn25