Skip to content

timm upgrade 0.6.12 #696

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 6 commits into from
Dec 15, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.6'
python-version: '3.7'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.black]
line-length = 119
target-version = ['py36', 'py37', 'py38']
target-version = ['py37', 'py38']
include = '\.pyi?$'
exclude = '''
/(
Expand All @@ -16,4 +16,4 @@ exclude = '''
| build
| dist
)/
'''
'''
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
torchvision>=0.5.0
pretrainedmodels==0.7.4
efficientnet-pytorch==0.7.1
timm==0.4.12
timm==0.6.12

tqdm
pillow
4 changes: 2 additions & 2 deletions segmentation_models_pytorch/encoders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def get_preprocessing_params(encoder_name, pretrained="imagenet"):

if encoder_name.startswith("tu-"):
encoder_name = encoder_name[3:]
if encoder_name not in timm.models.registry._model_has_pretrained:
if not timm.models.is_model_pretrained(encoder_name):
raise ValueError(f"{encoder_name} does not have pretrained weights and preprocessing parameters")
settings = timm.models.registry._model_default_cfgs[encoder_name]
settings = timm.models.get_pretrained_cfg(encoder_name)
else:
all_settings = encoders[encoder_name]["pretrained_settings"]
if pretrained not in all_settings.keys():
Expand Down
2 changes: 1 addition & 1 deletion segmentation_models_pytorch/encoders/timm_efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(self, stage_idxs, out_channels, depth=5, **kwargs):
def get_stages(self):
return [
nn.Identity(),
nn.Sequential(self.conv_stem, self.bn1, self.act1),
nn.Sequential(self.conv_stem, self.bn1),
self.blocks[: self._stage_idxs[0]],
self.blocks[self._stage_idxs[0] : self._stage_idxs[1]],
self.blocks[self._stage_idxs[1] : self._stage_idxs[2]],
Expand Down
51 changes: 26 additions & 25 deletions segmentation_models_pytorch/encoders/timm_regnet.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from ._base import EncoderMixin
from timm.models.regnet import RegNet
from timm.models.regnet import RegNet, RegNetCfg
import torch.nn as nn


class RegNetEncoder(RegNet, EncoderMixin):
def __init__(self, out_channels, depth=5, **kwargs):
kwargs["cfg"] = RegNetCfg(**kwargs["cfg"])
super().__init__(**kwargs)
self._depth = depth
self._out_channels = out_channels
Expand Down Expand Up @@ -141,95 +142,95 @@ def _mcfg(**kwargs):
"pretrained_settings": pretrained_settings["timm-regnetx_002"],
"params": {
"out_channels": (3, 32, 24, 56, 152, 368),
"cfg": _mcfg(w0=24, wa=36.44, wm=2.49, group_w=8, depth=13),
"cfg": _mcfg(w0=24, wa=36.44, wm=2.49, group_size=8, depth=13),
},
},
"timm-regnetx_004": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_004"],
"params": {
"out_channels": (3, 32, 32, 64, 160, 384),
"cfg": _mcfg(w0=24, wa=24.48, wm=2.54, group_w=16, depth=22),
"cfg": _mcfg(w0=24, wa=24.48, wm=2.54, group_size=16, depth=22),
},
},
"timm-regnetx_006": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_006"],
"params": {
"out_channels": (3, 32, 48, 96, 240, 528),
"cfg": _mcfg(w0=48, wa=36.97, wm=2.24, group_w=24, depth=16),
"cfg": _mcfg(w0=48, wa=36.97, wm=2.24, group_size=24, depth=16),
},
},
"timm-regnetx_008": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_008"],
"params": {
"out_channels": (3, 32, 64, 128, 288, 672),
"cfg": _mcfg(w0=56, wa=35.73, wm=2.28, group_w=16, depth=16),
"cfg": _mcfg(w0=56, wa=35.73, wm=2.28, group_size=16, depth=16),
},
},
"timm-regnetx_016": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_016"],
"params": {
"out_channels": (3, 32, 72, 168, 408, 912),
"cfg": _mcfg(w0=80, wa=34.01, wm=2.25, group_w=24, depth=18),
"cfg": _mcfg(w0=80, wa=34.01, wm=2.25, group_size=24, depth=18),
},
},
"timm-regnetx_032": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_032"],
"params": {
"out_channels": (3, 32, 96, 192, 432, 1008),
"cfg": _mcfg(w0=88, wa=26.31, wm=2.25, group_w=48, depth=25),
"cfg": _mcfg(w0=88, wa=26.31, wm=2.25, group_size=48, depth=25),
},
},
"timm-regnetx_040": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_040"],
"params": {
"out_channels": (3, 32, 80, 240, 560, 1360),
"cfg": _mcfg(w0=96, wa=38.65, wm=2.43, group_w=40, depth=23),
"cfg": _mcfg(w0=96, wa=38.65, wm=2.43, group_size=40, depth=23),
},
},
"timm-regnetx_064": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_064"],
"params": {
"out_channels": (3, 32, 168, 392, 784, 1624),
"cfg": _mcfg(w0=184, wa=60.83, wm=2.07, group_w=56, depth=17),
"cfg": _mcfg(w0=184, wa=60.83, wm=2.07, group_size=56, depth=17),
},
},
"timm-regnetx_080": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_080"],
"params": {
"out_channels": (3, 32, 80, 240, 720, 1920),
"cfg": _mcfg(w0=80, wa=49.56, wm=2.88, group_w=120, depth=23),
"cfg": _mcfg(w0=80, wa=49.56, wm=2.88, group_size=120, depth=23),
},
},
"timm-regnetx_120": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_120"],
"params": {
"out_channels": (3, 32, 224, 448, 896, 2240),
"cfg": _mcfg(w0=168, wa=73.36, wm=2.37, group_w=112, depth=19),
"cfg": _mcfg(w0=168, wa=73.36, wm=2.37, group_size=112, depth=19),
},
},
"timm-regnetx_160": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_160"],
"params": {
"out_channels": (3, 32, 256, 512, 896, 2048),
"cfg": _mcfg(w0=216, wa=55.59, wm=2.1, group_w=128, depth=22),
"cfg": _mcfg(w0=216, wa=55.59, wm=2.1, group_size=128, depth=22),
},
},
"timm-regnetx_320": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnetx_320"],
"params": {
"out_channels": (3, 32, 336, 672, 1344, 2520),
"cfg": _mcfg(w0=320, wa=69.86, wm=2.0, group_w=168, depth=23),
"cfg": _mcfg(w0=320, wa=69.86, wm=2.0, group_size=168, depth=23),
},
},
# regnety
Expand All @@ -238,95 +239,95 @@ def _mcfg(**kwargs):
"pretrained_settings": pretrained_settings["timm-regnety_002"],
"params": {
"out_channels": (3, 32, 24, 56, 152, 368),
"cfg": _mcfg(w0=24, wa=36.44, wm=2.49, group_w=8, depth=13, se_ratio=0.25),
"cfg": _mcfg(w0=24, wa=36.44, wm=2.49, group_size=8, depth=13, se_ratio=0.25),
},
},
"timm-regnety_004": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_004"],
"params": {
"out_channels": (3, 32, 48, 104, 208, 440),
"cfg": _mcfg(w0=48, wa=27.89, wm=2.09, group_w=8, depth=16, se_ratio=0.25),
"cfg": _mcfg(w0=48, wa=27.89, wm=2.09, group_size=8, depth=16, se_ratio=0.25),
},
},
"timm-regnety_006": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_006"],
"params": {
"out_channels": (3, 32, 48, 112, 256, 608),
"cfg": _mcfg(w0=48, wa=32.54, wm=2.32, group_w=16, depth=15, se_ratio=0.25),
"cfg": _mcfg(w0=48, wa=32.54, wm=2.32, group_size=16, depth=15, se_ratio=0.25),
},
},
"timm-regnety_008": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_008"],
"params": {
"out_channels": (3, 32, 64, 128, 320, 768),
"cfg": _mcfg(w0=56, wa=38.84, wm=2.4, group_w=16, depth=14, se_ratio=0.25),
"cfg": _mcfg(w0=56, wa=38.84, wm=2.4, group_size=16, depth=14, se_ratio=0.25),
},
},
"timm-regnety_016": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_016"],
"params": {
"out_channels": (3, 32, 48, 120, 336, 888),
"cfg": _mcfg(w0=48, wa=20.71, wm=2.65, group_w=24, depth=27, se_ratio=0.25),
"cfg": _mcfg(w0=48, wa=20.71, wm=2.65, group_size=24, depth=27, se_ratio=0.25),
},
},
"timm-regnety_032": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_032"],
"params": {
"out_channels": (3, 32, 72, 216, 576, 1512),
"cfg": _mcfg(w0=80, wa=42.63, wm=2.66, group_w=24, depth=21, se_ratio=0.25),
"cfg": _mcfg(w0=80, wa=42.63, wm=2.66, group_size=24, depth=21, se_ratio=0.25),
},
},
"timm-regnety_040": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_040"],
"params": {
"out_channels": (3, 32, 128, 192, 512, 1088),
"cfg": _mcfg(w0=96, wa=31.41, wm=2.24, group_w=64, depth=22, se_ratio=0.25),
"cfg": _mcfg(w0=96, wa=31.41, wm=2.24, group_size=64, depth=22, se_ratio=0.25),
},
},
"timm-regnety_064": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_064"],
"params": {
"out_channels": (3, 32, 144, 288, 576, 1296),
"cfg": _mcfg(w0=112, wa=33.22, wm=2.27, group_w=72, depth=25, se_ratio=0.25),
"cfg": _mcfg(w0=112, wa=33.22, wm=2.27, group_size=72, depth=25, se_ratio=0.25),
},
},
"timm-regnety_080": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_080"],
"params": {
"out_channels": (3, 32, 168, 448, 896, 2016),
"cfg": _mcfg(w0=192, wa=76.82, wm=2.19, group_w=56, depth=17, se_ratio=0.25),
"cfg": _mcfg(w0=192, wa=76.82, wm=2.19, group_size=56, depth=17, se_ratio=0.25),
},
},
"timm-regnety_120": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_120"],
"params": {
"out_channels": (3, 32, 224, 448, 896, 2240),
"cfg": _mcfg(w0=168, wa=73.36, wm=2.37, group_w=112, depth=19, se_ratio=0.25),
"cfg": _mcfg(w0=168, wa=73.36, wm=2.37, group_size=112, depth=19, se_ratio=0.25),
},
},
"timm-regnety_160": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_160"],
"params": {
"out_channels": (3, 32, 224, 448, 1232, 3024),
"cfg": _mcfg(w0=200, wa=106.23, wm=2.48, group_w=112, depth=18, se_ratio=0.25),
"cfg": _mcfg(w0=200, wa=106.23, wm=2.48, group_size=112, depth=18, se_ratio=0.25),
},
},
"timm-regnety_320": {
"encoder": RegNetEncoder,
"pretrained_settings": pretrained_settings["timm-regnety_320"],
"params": {
"out_channels": (3, 32, 232, 696, 1392, 3712),
"cfg": _mcfg(w0=232, wa=115.89, wm=2.53, group_w=232, depth=20, se_ratio=0.25),
"cfg": _mcfg(w0=232, wa=115.89, wm=2.53, group_size=232, depth=20, se_ratio=0.25),
},
},
}
6 changes: 3 additions & 3 deletions segmentation_models_pytorch/encoders/timm_sknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def load_state_dict(self, state_dict, **kwargs):
"out_channels": (3, 64, 64, 128, 256, 512),
"block": SelectiveKernelBasic,
"layers": [2, 2, 2, 2],
"zero_init_last_bn": False,
"zero_init_last": False,
"block_args": {"sk_kwargs": {"rd_ratio": 1 / 8, "split_input": True}},
},
},
Expand All @@ -84,7 +84,7 @@ def load_state_dict(self, state_dict, **kwargs):
"out_channels": (3, 64, 64, 128, 256, 512),
"block": SelectiveKernelBasic,
"layers": [3, 4, 6, 3],
"zero_init_last_bn": False,
"zero_init_last": False,
"block_args": {"sk_kwargs": {"rd_ratio": 1 / 8, "split_input": True}},
},
},
Expand All @@ -95,7 +95,7 @@ def load_state_dict(self, state_dict, **kwargs):
"out_channels": (3, 64, 256, 512, 1024, 2048),
"block": SelectiveKernelBottleneck,
"layers": [3, 4, 6, 3],
"zero_init_last_bn": False,
"zero_init_last": False,
"cardinality": 32,
"base_width": 4,
},
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
URL = "https://github.com/qubvel/segmentation_models.pytorch"
EMAIL = "qubvel@gmail.com"
AUTHOR = "Pavel Iakubovskii"
REQUIRES_PYTHON = ">=3.6.0"
REQUIRES_PYTHON = ">=3.7.0"
VERSION = None

# The rest you shouldn't have to touch too much :)
Expand Down