-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
Backbone kwargs in config #28784
Backbone kwargs in config #28784
Conversation
04f3fb2
to
cdc6e93
Compare
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. |
c55d529
to
f3d272c
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.
Could you explain the motivations behind this? IMO would should push users to use a config for the backbone, as we do for the quantization_config
for example.
I feel like `backbone = AutoBackbone.from_config(config.backbone_config, arg1 =x, arg2=y) could be used in the potential refactor?
Would help if you have a linked PR that has the expected behaviour to see how this is gonna be called 🤗
@ArthurZucker Sure! We want to remove the hard-coded conditional logic inside of models like DETR and be able to fully configure the backbone's behaviour. The use case is: image I want to create a new model to train. Instead of the default architecture of DETR, I want to use a different timm backbone, and I want the backbone to return different feature maps from the default. At the moment this isn't possible because:
I completely agree that it would be better to have this all as one argument! For context: when the backbones were first added, there were four arguments:
The backbone = AutoBackbone.from_config(backbone_config) and backbone = AutoBackbone.from_pretrained(backbone) So Adding If you want, I'm happy to code something up and we can decide which is best from the two :) For more context, here's an example of the final step for removing timm in the modeling files: https://github.com/amyeroberts/transformers/pull/114/files#diff-bdc82cb85f491576a99a341adabaf42260eac9cd797d70d0a2c564b0d4ee2930 You can see how all we need is a single call |
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.
Alright, looks good to me then!
bba8b2c
to
9fd1233
Compare
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
9fd1233
to
4877d32
Compare
* Enable instantiating model with pretrained backbone weights * Clarify pretrained import * Use load_backbone instead * Add backbone_kwargs to config * Pass kwargs to constructors * Fix up * Input verification * Add tests * Tidy up * Update tests/utils/test_backbone_utils.py Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com> --------- Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
* Enable instantiating model with pretrained backbone weights * Clarify pretrained import * Use load_backbone instead * Add backbone_kwargs to config * Pass kwargs to constructors * Fix up * Input verification * Add tests * Tidy up * Update tests/utils/test_backbone_utils.py Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com> --------- Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
What does this PR do?
This enables configuring the backbones through the config directly e.g. passing in
out_indices
to the backbone. This enables configuring a model's backbone when it's loaded from a pretrained checkpoint. At the moment, this is only possible when loading from abackbone_config
.Example:
This is necessary to replace th
timm
code currently there for models like DETR e.g. here, which is often hard coded.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.