-
Notifications
You must be signed in to change notification settings - Fork 32.9k
🚨 Delete duplicate code in backbone utils #43323
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
71f301b
draft
zucchini-nlp d0f4762
first make it work, then make pretty
zucchini-nlp 7ab4252
:eyes:
zucchini-nlp 56d3d0c
unused attributes?
zucchini-nlp ded5d7b
everythgin we need is in the config!
zucchini-nlp cb302df
push
zucchini-nlp a725f67
update
zucchini-nlp 3eae234
update
zucchini-nlp 0e7792b
fixes
zucchini-nlp 2323559
forgot
zucchini-nlp a69cbc6
push more changes
zucchini-nlp 5459482
move it out from mxin
zucchini-nlp 754b616
last test fixes i hope
zucchini-nlp dc3d676
delete backbone utils from utils
zucchini-nlp f7306fc
merge main
zucchini-nlp 49eda76
docs
zucchini-nlp a4f4b51
more docs updates
zucchini-nlp 06eb80c
remove backbone from args
zucchini-nlp a5d987d
docstring
zucchini-nlp 5063b0b
get rid of circular import and revert utils/backbonutils for BC
zucchini-nlp cd46e95
fix more tests
zucchini-nlp 35061b2
modular
zucchini-nlp 61acbc9
style run
zucchini-nlp a2f5b3b
Update src/transformers/modeling_backbone_utils.py
zucchini-nlp e68d5c1
Update src/transformers/modeling_backbone_utils.py
zucchini-nlp 5e20535
set and align output features from single entrypoint
zucchini-nlp 8c7864a
move init_backbone to '__init__'
zucchini-nlp ab2c275
calling init with timm backbone
zucchini-nlp 46c245c
maybe fix test
zucchini-nlp e8b063d
Merge branch 'main' into backbone
zucchini-nlp dea1f0a
fix tests
zucchini-nlp 4b1142a
fix more and new models as well
zucchini-nlp e8ef800
fix last test, maybe will move them to a common file
zucchini-nlp 3770829
fix repo
zucchini-nlp f020eff
fix repo
zucchini-nlp f34bb0d
tests unified, cannot be in common because models are very different
zucchini-nlp 72c223c
add in init
zucchini-nlp eb88a4c
make comment more detailed for future us
zucchini-nlp ac68691
Merge branch 'main' into backbone
zucchini-nlp 1f3d29b
fix modular
zucchini-nlp ea9ac12
update tests after DETR refactor
zucchini-nlp 223591c
rename `backbone_utils`
zucchini-nlp 509ffc4
delete bare `is_timm_available`
zucchini-nlp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 file contains hidden or 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 file contains hidden or 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 file contains hidden or 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 file contains hidden or 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 file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,13 +38,18 @@ Initialize [`DetrConfig`] with the pre-trained DINOv3 ConvNext backbone. Use `nu | |
| ```py | ||
| from transformers import DetrConfig, DetrForObjectDetection, AutoImageProcessor | ||
|
|
||
| config = DetrConfig(backbone="facebook/dinov3-convnext-large-pretrain-lvd1689m", | ||
| use_pretrained_backbone=True, use_timm_backbone=False, | ||
| # Create a model with randomly initialized weights | ||
| backbone_config = AutoConfig.from_pretrained("facebook/dinov3-convnext-large-pretrain-lvd1689m") | ||
| backbone = AutoBackbone.from_pretrained("facebook/dinov3-convnext-large-pretrain-lvd1689m") | ||
|
|
||
| config = DetrConfig(backbone_config=backbone_config, | ||
| num_labels=1, id2label={0: "license_plate"}, label2id={"license_plate": 0}) | ||
| model = DetrForObjectDetection(config) | ||
|
|
||
| for param in model.model.backbone.parameters(): | ||
| param.requires_grad = False | ||
| # Assign pretrained backbone checkpoint and freeze the weights | ||
| model.model.backbone = backbone | ||
| model.model.freeze_backbone() | ||
|
Comment on lines
+49
to
+51
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. backbones are usually set under different module names, so I'm thinking we can add a Maybe next PR, this one is already big |
||
|
|
||
| image_processor = AutoImageProcessor.from_pretrained("facebook/detr-resnet-50") | ||
| ``` | ||
|
|
||
|
|
||
This file contains hidden or 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 file contains hidden or 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 file contains hidden or 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
Oops, something went wrong.
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.
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.
use_timm_backboneis not really needed imo. We can infer if the requested checkpoint is from timm or HF by checking if repo exists on the hub with a valid configDeleted it as well as a redudant arg