Add support for decoding 16bits png#8524
Merged
NicolasHug merged 8 commits intopytorch:mainfrom Jul 15, 2024
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8524
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 4 New FailuresAs of commit 10cbad7 with merge base 6344041 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
facebook-github-bot
pushed a commit
that referenced
this pull request
Aug 2, 2024
Reviewed By: vmoens Differential Revision: D60596240 fbshipit-source-id: 4987658c3ee1255a3200232768580a927e371d12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for decoding 16bits png in
read_image,decode_imageanddecode_png.It also adds proper support and tests to convert the resuting
torch.uint16tensor into uint8/float32 tensor viato_dtype().Note: decoding 16bits pngs was previously supported via a private API that we had to enable to support RAFT. At the time, the
torch.uint16dtype didn't exist, so we had to return atorch.int32tensor. Support fortorch.uint16was recently added in pytorch. The dtype exists, but very few operators are implemented for it. In our decoder docs, we strongly encourage users to callto_dtype(..., scale=True)to convert the resulting uint16 tensor into a supported dtype like uint8 or float.Re the "old" v1
F.convert_image_dtype(): uint16 -> float32 works, but-> uint8fails with a loud error. It's OK, we want users to use the v2to_dtypeanyway.Closes #4731