-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Update timm to 1.* version and support more encoders #885
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b87b1cf
Update reqs
qubvel a9b7715
Update timm universal encoder
qubvel bf15cbd
Update handling of channels for depth
qubvel 2f82fe8
Support for different architectures (3 versions)
qubvel e9e70b4
[WIP] timm encoder
qubvel 6d6aae4
Refactor timm universal, add visualize()
qubvel 7b52f9d
Add features info str
qubvel 3dbe42d
Add notebook for timm encoders
qubvel 7ad4317
Adjust timm universal
qubvel b08a563
Add features_info_str (not implemented)
qubvel 5d2fe49
Fix typehints
qubvel 072f3f8
Remove warning about channels
qubvel 553c5ab
Add encoder indices and channels (Unet)
qubvel 5934e82
Make download if needed (optional)
qubvel d24b3fa
Fix indices and channels handling
qubvel 0185105
Update min python to 3.8
qubvel 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
There are no files selected for viewing
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 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 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
torchvision>=0.5.0 | ||
pretrainedmodels==0.7.4 | ||
efficientnet-pytorch==0.7.1 | ||
timm==0.9.7 | ||
timm>1.0.0 | ||
|
||
tqdm | ||
pillow | ||
six | ||
loguru |
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 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 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 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 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 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 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
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,7 @@ | ||||||||||||||||||||||
import timm | ||||||||||||||||||||||
import functools | ||||||||||||||||||||||
import torch.utils.model_zoo as model_zoo | ||||||||||||||||||||||
from loguru import logger | ||||||||||||||||||||||
|
||||||||||||||||||||||
from .resnet import resnet_encoders | ||||||||||||||||||||||
from .dpn import dpn_encoders | ||||||||||||||||||||||
|
@@ -51,6 +52,10 @@ | |||||||||||||||||||||
def get_encoder(name, in_channels=3, depth=5, weights=None, output_stride=32, **kwargs): | ||||||||||||||||||||||
if name.startswith("tu-"): | ||||||||||||||||||||||
name = name[3:] | ||||||||||||||||||||||
|
||||||||||||||||||||||
if "encoder_indices" in kwargs and kwargs["encoder_indices"] is None: | ||||||||||||||||||||||
kwargs["encoder_indices"] = "first" | ||||||||||||||||||||||
|
||||||||||||||||||||||
encoder = TimmUniversalEncoder( | ||||||||||||||||||||||
name=name, | ||||||||||||||||||||||
in_channels=in_channels, | ||||||||||||||||||||||
|
@@ -61,6 +66,18 @@ def get_encoder(name, in_channels=3, depth=5, weights=None, output_stride=32, ** | |||||||||||||||||||||
) | ||||||||||||||||||||||
return encoder | ||||||||||||||||||||||
|
||||||||||||||||||||||
encoder_indices = kwargs.pop("encoder_indices", None) | ||||||||||||||||||||||
if encoder_indices is not None: | ||||||||||||||||||||||
logger.warning( | ||||||||||||||||||||||
"Argument `encoder_indices` is supported only for `tu-` encoders (Timm) and will be ignored." | ||||||||||||||||||||||
) | ||||||||||||||||||||||
Comment on lines
+69
to
+73
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.
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
encoder_channels = kwargs.pop("encoder_channels", None) | ||||||||||||||||||||||
if encoder_channels is not None: | ||||||||||||||||||||||
logger.warning( | ||||||||||||||||||||||
"Argument `encoder_channels` is supported only for `tu-` encoders (Timm) and will be ignored." | ||||||||||||||||||||||
) | ||||||||||||||||||||||
|
||||||||||||||||||||||
try: | ||||||||||||||||||||||
Encoder = encoders[name]["encoder"] | ||||||||||||||||||||||
except KeyError: | ||||||||||||||||||||||
|
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
Oops, something went wrong.
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.
While it's called
encoder_indices
in the functionselect_feature_indices
, inTimmUniversalEncoder
it is still calledout_indices