Skip to content
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

Add support for decoding 16bits png #8524

Merged
merged 8 commits into from
Jul 15, 2024
Merged

Conversation

NicolasHug
Copy link
Member

@NicolasHug NicolasHug commented Jul 12, 2024

This PR adds support for decoding 16bits png in read_image, decode_image and decode_png.

It also adds proper support and tests to convert the resuting torch.uint16 tensor into uint8/float32 tensor via to_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.uint16 dtype didn't exist, so we had to return a torch.int32 tensor. Support for torch.uint16 was recently added in pytorch. The dtype exists, but very few operators are implemented for it. In our decoder docs, we strongly encourage users to call to_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 -> uint8 fails with a loud error. It's OK, we want users to use the v2 to_dtype anyway.

Closes #4731

Copy link

pytorch-bot bot commented Jul 12, 2024

🔗 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 SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 4 New Failures

As of commit 10cbad7 with merge base 6344041 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@NicolasHug NicolasHug merged commit 33e47d8 into pytorch:main Jul 15, 2024
79 of 83 checks passed
@NicolasHug NicolasHug deleted the add_16bits_png branch July 15, 2024 11:39
facebook-github-bot pushed a commit that referenced this pull request Aug 2, 2024
Reviewed By: vmoens

Differential Revision: D60596240

fbshipit-source-id: 4987658c3ee1255a3200232768580a927e371d12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

16 bits png support and compatibility with current transforms
2 participants