Skip to content

Update timm library to 0.4.12 #429

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 1 commit into from
Jul 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
torchvision>=0.3.0
torchvision>=0.5.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretrainedmodels==0.7.4
efficientnet-pytorch==0.6.3
timm==0.3.2
timm==0.4.12
8 changes: 4 additions & 4 deletions segmentation_models_pytorch/encoders/timm_efficientnet.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from functools import partial

import torch
import torch.nn as nn

Expand Down Expand Up @@ -41,9 +43,8 @@ def get_efficientnet_kwargs(channel_multiplier=1.0, depth_multiplier=1.0, drop_r
block_args=decode_arch_def(arch_def, depth_multiplier),
num_features=round_channels(1280, channel_multiplier, 8, None),
stem_size=32,
channel_multiplier=channel_multiplier,
round_chs_fn=partial(round_channels, multiplier=channel_multiplier),
act_layer=Swish,
norm_kwargs={}, # TODO: check
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no more norm_kwargs and channel_multiplier options.
norm_kwargs was not used, so I just delete it, but in the case of channel_multiplier, you can still pass it shrough the new round_chs_fn argument.

See huggingface/pytorch-image-models@c4f482a#diff-27c2bbd967991cbb5264f93cb5da34895fdab02424b2cc8c63d3d0768e65d47aR490

drop_rate=drop_rate,
drop_path_rate=0.2,
)
Expand Down Expand Up @@ -81,9 +82,8 @@ def gen_efficientnet_lite_kwargs(channel_multiplier=1.0, depth_multiplier=1.0, d
num_features=1280,
stem_size=32,
fix_stem=True,
channel_multiplier=channel_multiplier,
round_chs_fn=partial(round_channels, multiplier=channel_multiplier),
act_layer=nn.ReLU6,
norm_kwargs={},
drop_rate=drop_rate,
drop_path_rate=0.2,
)
Expand Down
4 changes: 2 additions & 2 deletions segmentation_models_pytorch/encoders/timm_sknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def load_state_dict(self, state_dict, **kwargs):
'block': SelectiveKernelBasic,
'layers': [2, 2, 2, 2],
'zero_init_last_bn': False,
'block_args': {'sk_kwargs': {'min_attn_channels': 16, 'attn_reduction': 8, 'split_input': True}}
'block_args': {'sk_kwargs': {'rd_ratio': 1/8, 'split_input': True}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. attn_reduction was changed to rd_ratio and the value is inversed. So old attn_reduction equals to new 1 / rd_ratio

See huggingface/pytorch-image-models@307a935#diff-69a503e8326443f3698de117aa9ac39e8fbb9ce52dfa7783c6708fe6a38f6e87R52

  1. There is no more min_attn_channels. I did not find an easy way to keep it here and I think it is fine to just delete it.

See huggingface/pytorch-image-models@bda8ab0#diff-69a503e8326443f3698de117aa9ac39e8fbb9ce52dfa7783c6708fe6a38f6e87R52

}
},
'timm-skresnet34': {
Expand All @@ -85,7 +85,7 @@ def load_state_dict(self, state_dict, **kwargs):
'block': SelectiveKernelBasic,
'layers': [3, 4, 6, 3],
'zero_init_last_bn': False,
'block_args': {'sk_kwargs': {'min_attn_channels': 16, 'attn_reduction': 8, 'split_input': True}}
'block_args': {'sk_kwargs': {'rd_ratio': 1/8, 'split_input': True}}
}
},
'timm-skresnext50_32x4d': {
Expand Down