-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Explicitly copying array in pil_to_tensor #4566
Explicitly copying array in pil_to_tensor #4566
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the contribution Joao.
We can merge after a green CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @jdsgomes!
torchvision/transforms/functional.py
Outdated
@@ -161,6 +161,10 @@ def pil_to_tensor(pic): | |||
|
|||
Returns: | |||
Tensor: Converted image. | |||
|
|||
.. note:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this note, such documentation is important
Let's also add it to to the PILToTensor transform, since it relies on pil_to_tensor
.
Also, maybe put it above the Args: section for it to have better visibility?
Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jdsgomes ! Last comment to fix the docs, but LGTM when addressed
Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
* mExplicitly copying array in pil_to_tensor * Update torchvision/transforms/functional.py Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> * Adding comments regarding implicit array deep copy in PILToTensor transform * Update torchvision/transforms/transforms.py Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
* mExplicitly copying array in pil_to_tensor * Update torchvision/transforms/functional.py Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> * Adding comments regarding implicit array deep copy in PILToTensor transform * Update torchvision/transforms/transforms.py Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com> Co-authored-by: Joao Gomes <joaopsgomes@gmail.com> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
Summary: * mExplicitly copying array in pil_to_tensor * Update torchvision/transforms/functional.py * Adding comments regarding implicit array deep copy in PILToTensor transform * Update torchvision/transforms/transforms.py Reviewed By: NicolasHug Differential Revision: D31505570 fbshipit-source-id: a2ce1c5cf6b70236bc71a79a3d190ddac7d378a4 Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
* mExplicitly copying array in pil_to_tensor * Update torchvision/transforms/functional.py Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> * Adding comments regarding implicit array deep copy in PILToTensor transform * Update torchvision/transforms/transforms.py Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
* mExplicitly copying array in pil_to_tensor * Update torchvision/transforms/functional.py Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> * Adding comments regarding implicit array deep copy in PILToTensor transform * Update torchvision/transforms/transforms.py Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
In order to avoid
UserWarning
when callingpil_to_tensor
we are making a deep copy of the underlying array when converting fromPIL Image
toTensor
.fixes #4508
cc @vfdev-5 @datumbox