-
Notifications
You must be signed in to change notification settings - Fork 27k
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 validate images and text inputs order util for processors and test_processing_utils #33285
Add validate images and text inputs order util for processors and test_processing_utils #33285
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
CI failing because of this #32406 it seems |
src/transformers/processing_utils.py
Outdated
return True | ||
elif isinstance(t[0][0], (list, tuple)): | ||
# ... list of list of list of int (for list of list of encoded inputs) | ||
return isinstance(t[0][0][0], int) |
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.
Reminder to remove the int checks in this function
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.
Oops, should be good now
81c25de
to
d7aeafc
Compare
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.
Looks great - thanks for adding this!
src/transformers/processing_utils.py
Outdated
if isinstance(t, str): | ||
# Strings are fine | ||
return True | ||
elif isinstance(t, (list, tuple)): | ||
# List are fine as long as they are... | ||
if len(t) == 0: | ||
# ... not empty | ||
return False | ||
elif isinstance(t[0], str): | ||
# ... list of strings | ||
return True | ||
elif isinstance(t[0], (list, tuple)): | ||
# ... list of list of strings | ||
return isinstance(t[0][0], str) |
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.
This can be re-written to be recursive
…t_processing_utils (huggingface#33285) * Add validate images and test processing utils * Remove encoded text from possible inputs in tests * Removed encoded inputs as valid in processing_utils * change text input check to be recursive * change text check to all element of lists and not just the first one in recursive checks
What does this PR do?
Add validate images and text inputs order util that will be used as a tool to preserve backward compatibility during the transition to uniform kwargs (#31911).
Add corresponding tests in test_processing_utils.py (didn't exist before).
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.