-
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
Fix overshoot issue in F.to_pil_image #3610
Conversation
Hi @Coloquinte! 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! |
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.
I think these are reasonable changes, thanks @Coloquinte .
It'd be nice to also have a simple non-regression test in test/test_transforms.py
, with a reference to this PR as a comment (it's often easier than to follow git blame)
Although the failing tests seem related: would you mind looking at these? |
Thanks! I fixed the transform tests and added mine. I'm letting the CI do the checks, so there may be one more round. It seems that some tests were failing due to the branch being a fork. I don't know how to workaround these. |
When converting a tensor to a PIL image, overshoots are not clamped. This means that a value of 1.001 becomes 0 instead of 255. This issue is described here: #2950 (comment) Additionally, replace the imprecise truncation by a rounding. Both issues are particularly annoying for downsampling/upsampling code, where such overshoots are common.
The following error is still present during the CI run:
Is there anything to do on my side to help merge this? |
Hi @Coloquinte The torchub failure is unrelated, don't worry. I'll have a closer look at the PR on Monday, but here is my quick thoughts about it:
I think it might be safer to remove the |
Hi @fmassa, Thanks, no hurry. I can confirm that In my opinion, round() is necessary because it has the lowest error for |
Hi, |
Hi @Coloquinte , thanks for your patience. I took care of porting the tests to our new testing infra (with pytest).
I think having such round-trip test would be great, yes! We could even parametrize it over a few epsilon values and do |
Thanks @NicolasHug ! I pushed such a test on my branch |
Hi @Coloquinte , I fixed the failing tests that resulted from a problem during the |
When converting a tensor to a PIL image, overshoots are not clamped. This means that a value of 1.001 becomes 0 instead of 255. This issue is described here: #2950 (comment)
Additionally, replace the imprecise truncation by a rounding.
Both issues are particularly annoying for downsampling/upsampling code, where such overshoots are common.