Conversation
resize() converts through PIL, which only accepts [0, 1] or [0, 255]. After normalize(), values are signed floats, so resize raised ValueError. Temporarily map out-of-range arrays to [0, 1], resize, then map back; bilinear resampling is linear so the float field is preserved. Arrays already accepted by the PIL path are unchanged. Fixes huggingface#34920
Contributor
CI recapDashboard: View test results in Grafana |
zucchini-nlp
left a comment
Member
There was a problem hiding this comment.
hmm, not sure if we want it since this atp, a very old issue with no community interest. Also this is not the correct fix (see #34994 (review))
I'd say we close the linked PRs and the issue as not-planned
Author
|
Got it — thanks for the pointer to the earlier review. Fine to close this and the linked issue as not-planned. |
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.
What does this PR do?
Fixes #34920.
I ran into
ValueErrorwhen callingresize()afternormalize()— the PIL conversion path only accepts[0, 1]or[0, 255], and normalized tensors are signed floats. I catch that case, temporarily map the array into[0, 1], resize, then map back. Bilinear resampling is linear, so the float field comes back in the original range. Arrays that already pass the PIL checks are unchanged (including float images in[0, 255]).Added a regression test for normalize→resize, float-255 inputs, and a constant out-of-range image.
Before submitting
transformers.image_transforms.resizedoesnot work for negative values #34920Who can review?
@qubvel @amyeroberts