-
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
fixed Gamma casting #3472
fixed Gamma casting #3472
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.
@sanketsans Please avoid opening new PRs in relation to this, so that we can keep track of the discussions in one place (for future reference previously related PRs are #3470, #3471).
As you can see your current PR breaks the unit-tests. This is because the convert_image_dtype()
does more than converting the image to specific dtype and thus can't be replaced with a simple to()
. As discussed at #3067 (comment) and #3471, the only necessary modification for fixing the issue is just to remove the unnecessary to()
call.
If you decide to update this PR with the requested change, please ping me to review it again. Thanks!
Modified the .to() method to convert_image_dtype() method.
@datumbox Sorry about multiple PRs. I will make sure to avoid it in the future. |
Codecov Report
@@ Coverage Diff @@
## master #3472 +/- ##
==========================================
- Coverage 78.70% 78.69% -0.01%
==========================================
Files 105 105
Lines 9705 9704 -1
Branches 1555 1555
==========================================
- Hits 7638 7637 -1
Misses 1576 1576
Partials 491 491
Continue to review full report at Codecov.
|
Summary: * fixed origin head * fixed inconsistent casting * updated functional_tensor.py Modified the .to() method to convert_image_dtype() method. * Apply suggestions from code review Reviewed By: NicolasHug, cpuhrsch Differential Revision: D26945731 fbshipit-source-id: eab2e30c37bc1d29cae2d0921c869af22b49866a Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
Fixes #3067
Removed the double casting of the result to the original dtype.
Now, the casting is only done if the original dtype is different from float32 type which is used to adjust the gamma of the image / tensor.
Since the method requires the image dtype to be in float format. If not, then line no. 400 converts it to the float format. Then needs just one check to change it back to its original format. If it is already in float format then we don't need to change it.
vision/torchvision/transforms/functional_tensor.py
Lines 397 to 406 in 9e71fda