Fix Pillow 12.0.0 compatibility for uint16 multi-channel images#11149
Closed
0AnshuAditya0 wants to merge 2 commits intotensorflow:masterfrom
Closed
Fix Pillow 12.0.0 compatibility for uint16 multi-channel images#111490AnshuAditya0 wants to merge 2 commits intotensorflow:masterfrom
0AnshuAditya0 wants to merge 2 commits intotensorflow:masterfrom
Conversation
The old OneDrive API v1.0 URLs were returning HTTP 400 errors. Updated to new OneDrive share links from the official Microsoft Research page. Fixes tensorflow#11136
Pillow 12.0.0 removed support for creating multi-channel (RGB/RGBA) images from uint16 numpy arrays via fromarray(). The _fromarray_typemap no longer includes keys like ((1, 1, 3), '<u2') and ((1, 1, 4), '<u2'). This change converts uint16 RGB/RGBA images to uint8 in create_thumbnail() by scaling from 16-bit (0-65535) to 8-bit (0-255) range before passing to PIL's fromarray(). Single-channel uint16 images maintain original behavior. Fixes tensorflow#11148
Merged
13 tasks
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.
Description
Fixes #11148
This PR fixes test failures in
ImageFeatureTestwhen using Pillow 12.0.0. The tests were failing withTypeError: Cannot handle this data type: (1, 1, 3), <u2for uint16 multi-channel images.Root Cause
Pillow 12.0.0 removed support for creating multi-channel (RGB/RGBA) images from uint16 numpy arrays via
fromarray(). The_fromarray_typemapno longer includes type keys like((1, 1, 3), '<u2')and((1, 1, 4), '<u2').Changes
create_thumbnail()intensorflow_datasets/core/utils/image_utils.py'I;16'mode behaviorTesting
ImageFeatureTesttests now pass with Pillow 12.0.0Compatibility