-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Add normalize to image transforms module #19544
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 normalize to image transforms module #19544
Conversation
…ormers into image-processor-mixin
Co-authored-by: Sylvain Gugger <[email protected]> Co-authored-by: Sylvain Gugger <[email protected]>
Use PIL.Image.XXX resampling values instead of PIL.Image.Resampling.XXX enum as it's only in the recent version >= 9.10 and version is not yet pinned and older version support deprecated
|
The documentation is not available anymore as the PR was closed or merged. |
sgugger
left a comment
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.
Thanks for working on this, it's very clean!
src/transformers/image_transforms.py
Outdated
| The channel dimension format of the output image. If `None`, will use the inferred format from the input. | ||
| """ | ||
| if isinstance(image, PIL.Image.Image): | ||
| warnings.warn("PIL will not be supported as input in the next release. Please use numpy arrays instead.") |
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.
| warnings.warn("PIL will not be supported as input in the next release. Please use numpy arrays instead.") | |
| warnings.warn("PIL will not be supported as input in the next release. Please use numpy arrays instead.", FutureWarning) |
Also, please be explicit about the version: is it 4.25.0 (since we're developing 4.24.0 right now) or 5?
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.
Good point. Do we have a rule of thumb for how many releases we normally support?
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.
Normally we only do breaking changes at major releases, but for this one we're making an exception with a short deprecation cycle. Just checked with Lysandre and we should support the deprecation for two minors and fully remove this in 4.26.0 if that makes sense.
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.
Yep, makes sense! I'll update the warning message.
alaradirik
left a comment
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.
Everything looks good to me!
NielsRogge
left a comment
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.
Thanks for adding! Looks good to me.
Co-authored-by: Sylvain Gugger <[email protected]>
What does this PR do?
Adds
normalizeto the image transforms modules, as well as a helper utility functionget_channel_dimension_axis.normalize: performs equivalent normalization of an image as previous feature extractorsget_channel_dimension_axis: Helper function which returns which axis number the channel dimension is on.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.