-
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
Avoid using uncessary get_values(MODEL_MAPPING)
#29362
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. |
cc @NielsRogge For future vision models, let's avoid using |
|
"PerceiverForImageClassificationLearned", | ||
"PerceiverForImageClassificationFourier", | ||
"PerceiverForImageClassificationConvProcessing", | ||
*MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES.values(), |
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.
Using stuff like MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES.values()
is not reliable, as an element in MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES.values()
maybe a list itself. For example, we have
(
"perceiver",
(
"PerceiverForImageClassificationLearned",
"PerceiverForImageClassificationFourier",
"PerceiverForImageClassificationConvProcessing",
),
),
in MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES
.
It's probably better to have something like _get_names_for_values
: similar to get_values
in src/transformers/models/auto/auto_factory.py
but only return names without loading the classes.
I could do that in a follow up PR, or any better suggestion.
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.
yeah it's faster also to not load the classes and just compare strings
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.
Love that it is simpler 😉
"PerceiverForImageClassificationLearned", | ||
"PerceiverForImageClassificationFourier", | ||
"PerceiverForImageClassificationConvProcessing", | ||
*MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES.values(), |
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.
yeah it's faster also to not load the classes and just compare strings
* more fixes * more fixes --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
What does this PR do?
When we switch to torch 2.2 in daily CI,
natten
causing issue and I temporarily disabled its installation. However, some test files usemodel_class in get_values(MODEL_MAPPING)
which will fail witheven if those models are not requiring
natten
.The usage of
is slow and unnecessary, we can just use the names (string) rather than import them to get the classes.
This PR changes them to use the class name strings.