-
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
Replace byte tensor #3813
Replace byte tensor #3813
Conversation
Hi @vipyoung! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
@datumbox thanks for pinging.
@fmassa even self-assigned himself to fix #3666 , I let him review this PR as well. @vipyoung this flake8 failure is related : https://app.circleci.com/pipelines/github/pytorch/vision/8023/workflows/9179c017-9365-410e-8959-e77c94a37c26/jobs/571724 |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
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.
The code looks great, thanks a lot @vipyoung !
There are lint failures in https://app.circleci.com/pipelines/github/pytorch/vision/8023/workflows/9179c017-9365-410e-8959-e77c94a37c26/jobs/571724 , can you look into fixing those so that we can merge the PR?
Additionally, one thing we might want to consider as well is that we now get the following warning for the uint8
use-case (which we didn't have before)
/root/project/torchvision/transforms/functional.py:129: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at /opt/conda/conda-bld/pytorch_1620716760038/work/torch/csrc/utils/tensor_numpy.cpp:180.)
np.array(pic, mode_to_nptype.get(pic.mode, np.uint8), copy=False)
see https://app.circleci.com/pipelines/github/pytorch/vision/8023/workflows/5620d2f7-08be-493d-9878-fcb5db93539f/jobs/571690 for one example.
We might want think if we want to perform the copy here (which will be less efficient), or suppress this warning somehow.
Thoughts @vfdev-5 ?
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.
I've fixed the lint issues and enabled copy of the array here as a quick fix to the warning.
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 a lot!
replaced byteTensor with from_numpy fixed lint issues and copy related worning
df3f9d3
to
fc1a060
Compare
Summary: replaced byteTensor with from_numpy fixed lint issues and copy related worning Reviewed By: vincentqb, cpuhrsch Differential Revision: D28677160 fbshipit-source-id: b508d40651e6e7453e8855fed9edc4f313c7580f Co-authored-by: Sofiane Abbar <sofa@fb.com> Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
replaced the deprecated byteTensor call with from_numpy.
Also slightly refactored the code.