-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
ImageProcessor - check if input pixel values between 0-255 #25688
ImageProcessor - check if input pixel values between 0-255 #25688
Conversation
The documentation is not available anymore as the PR was closed or merged. |
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, left a few nits on the doc!
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.
I guess we can also update the doc here
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.
same here I guess
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.
here too!
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.
And here
@@ -236,6 +237,11 @@ def _preprocess_image( | |||
"""Preprocesses a single image.""" | |||
# All transformations expect numpy arrays. | |||
image = to_numpy_array(image) | |||
if _is_scaled_image(image) and do_rescale: |
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.
Do you think it makes sense to also set do_rescale = False
?
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.
I don't want to do anything "magic" and surprise the user.
Checking whether the pixels are correct isn't a perfect test, and it'd be modifying the processor behaviour under an assumption.
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.
Do was updated but forward does not have do_rescale
and check not used
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.
doc needs to be udpated to?
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.
docstring can be updated to
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.
Only doc was updated, but no do_rescale
exists
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.
doc can be updated!
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.
Nice work! 🙂
src/transformers/models/layoutlmv2/image_processing_layoutlmv2.py
Outdated
Show resolved
Hide resolved
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.
Thank you!
@rafaelpadilla @ArthurZucker Thanks bot for your detailed reviews! I've added the suggested updated: making the function name consistent with others |
…ce#25688) * Check if pixel values between 0-255 and add doc clarification * Add missing docstrings * _is_scale_image -> is_scaled_image * Spelling is hard * Tidy up
…ce#25688) * Check if pixel values between 0-255 and add doc clarification * Add missing docstrings * _is_scale_image -> is_scaled_image * Spelling is hard * Tidy up
…ce#25688) * Check if pixel values between 0-255 and add doc clarification * Add missing docstrings * _is_scale_image -> is_scaled_image * Spelling is hard * Tidy up
What does this PR do?
Adds a warning in the image processor if the user is passing in images that have already had their pixel values rescale between 0 and 1 and
do_rescale=True
. Additionally adds information in the docstring.This has caused some confusion and error reports recently, when users have been passing in images that have already been partially transformed.
Related issues: #25195, #24857, #23096
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.