-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Update timm universal (support transformer-style model) #1004
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 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
363a361
Update timm_universal.py
brianhou0208 f07e107
Fix ruff style and typing
brianhou0208 ea725dd
Update encoders_timm.rst
brianhou0208 029c190
Fix typo error
brianhou0208 c58b7cf
Fix typo error & Update doc
brianhou0208 eae7e2b
Fix typo error
brianhou0208 4148788
Support channel-last format
brianhou0208 51a4d7b
Update encoders_timm.rst
brianhou0208 8b0fece
Update timm_universal.py
brianhou0208 330e6e5
Fix ruff style
brianhou0208 d8ea35f
Update timm_universal.py
brianhou0208 e7bc6e0
Add tests/test_models & fix type
brianhou0208 dd25aa2
Update test_models.py
brianhou0208 f55eb13
Update test_models.py
brianhou0208 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
Update timm_universal.py
- Loading branch information
commit 8b0fece33cfabf89b75c12c6d929b53b3caa692e
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
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.
Why do we need to load a temporary model? I would try to avoid it if possible.
Uh oh!
There was an error while loading. Please reload this page.
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.
I believe that a temporary model is necessary because we need to determine
feature_info.reduction()
to classify the model as traditional, transformer, or VGG style. This affects the range ofout_indices
to be used:depth == 5
,out_indices
is(0, 1, 2, 3, 4)
(0, 1, 2, 3)
(0, 1, 2, 3, 4, 5)
depth == 3
,out_indices
is(0, 1, 2)
(0, 1)
(0, 1, 2, 3)
Is there any other way to determine
feature_info.reduction()
in advance?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.
Can we slice features in
forward
instead of providing "out_indicies"? Otherwise, I would recommend usingpretrained=False
for the tmp model and maybe initialize it on the meta device to avoid double memory consumption.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.
In
timm.create_model()
, default ispretrained=False
I think initialize tmp model to
torch.device("meta")
is goodwhat do you think?
Uh oh!
There was an error while loading. Please reload this page.
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.
Explicit
pretrained=False
would be nice, for meta it should be something like this:+ without
self.
+ let's name it with
tmp_
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.
lets leave it as is for now, it can be optimized later if needed
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.
If we don't use additional variable names, it shouldn't take up extra memory?
renamed
temp_model
toself.model
Although the variable names will be a little confusing.
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.
As is I mean:
sorry for the confusuion
Uh oh!
There was an error while loading. Please reload this page.
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.
don't think so, we still allocate twice.
self.model
self.model
var name and link required onetwo models exist at a time
Uh oh!
There was an error while loading. Please reload this page.
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.
I think you are right, thanks for your explanation