Skip to content

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

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
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

zshn25
Copy link
Contributor

@zshn25 zshn25 commented Jul 28, 2023

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

Changed RandomOrder to use torch randperm and thus make it Scriptable
@pytorch-bot
Copy link

pytorch-bot bot commented Jul 28, 2023

🔗 Helpful Links

🧪 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.

@zshn25
Copy link
Contributor Author

zshn25 commented Jul 31, 2023

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 zshn25 mentioned this pull request Aug 1, 2023
@zshn25
Copy link
Contributor Author

zshn25 commented Aug 1, 2023

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

It is due to pytorch/pytorch#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 zshn25 changed the title Scriptable RandomOrder RandomOrder transform now accepts torch.Tensor and works well with torch.seed Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants