-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Image + text + audio uniform processors #30511
Open
molbap
wants to merge
97
commits into
huggingface:main
Choose a base branch
from
molbap:image_text_audio_processors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
This parameter depends on tokenizers received.
gafrom
reviewed
Aug 7, 2024
feature_extractor = None | ||
if "feature_extractor" in kwargs: | ||
def __init__(self, image_processor=None, tokenizer=None, feature_extractor=None): | ||
if "feature_extractor": |
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.
Always true? (same in other places)
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?
This PR is a stab at uniformizing the processors across all transformers models. If we are happy with the design, I'll expand it to all existing models. It only touches on some text + audio and text + images models as experiment subjects. Linked with #28711 which has a larger scope, and several previous discussions with team members.
Usage
As before, kwargs that are passed to processors at
__call__
time take priority. However, per-modality processors can be instantiated with their own kwargs, and if they are not overriden at call time, they will serve as defaults.Type hinting of kwargs is preserved if they are passed as structured dictionary entries
It also works with kwargs passed without nesting:
Merging of kwargs and handling priority order is done in
processing_utils
through a dedicated method.The order of operations is as follows:
What changes:
ProcessingKwargs
TypedDict of kwargs that inherits fromImagesKwargs
,TextKwargs
, and so on.TypedDict
that does not need to be total. We can expand this typed dict (inprocessing_utils
) as processors get uniformized.kwargs
set by a user will always override default processing kwargs.call
.What that allows:
Limitations:
Tests pass (I think). What's missing:
Who can review?
Models: