Skip to content

Commit 740f32c

Browse files
committed
Add ECA-NFNet-L0 weights and update model name. Update README and bump version to 0.4.6
1 parent 5e2e4e7 commit 740f32c

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ I'm fortunate to be able to dedicate significant time and money of my own suppor
2323

2424
## What's New
2525

26+
### March 17, 2021
27+
* Add new ECA-NFNet-L0 (rename `nfnet_l0c`->`eca_nfnet_l0`) weights trained by myself.
28+
* 82.6 top-1 @ 288x288, 82.8 @ 320x320, trained at 224x224
29+
* Uses SiLU activation, approx 2x faster than `dm_nfnet_f0` and 50% faster than `nfnet_f0s` w/ 1/3 param count
30+
* Integrate [Hugging Face model hub](https://huggingface.co/models) into timm create_model and default_cfg handling for pretrained weight and config sharing (more on this soon!)
31+
* Merge HardCoRe NAS models contributed by https://github.com/yoniaflalo
32+
* Merge PyTorch trained EfficientNet-EL and pruned ES/EL variants contributed by [DeGirum](https://github.com/DeGirum)
33+
34+
2635
### March 7, 2021
2736
* First 0.4.x PyPi release w/ NFNets (& related), ByoB (GPU-Efficient, RepVGG, etc).
2837
* Change feature extraction for pre-activation nets (NFNets, ResNetV2) to return features before activation.
@@ -171,6 +180,7 @@ A full version of the list below with source links can be found in the [document
171180
* MobileNet-V2 - https://arxiv.org/abs/1801.04381
172181
* Single-Path NAS - https://arxiv.org/abs/1904.02877
173182
* GPU-Efficient Networks - https://arxiv.org/abs/2006.14090
183+
* HardCoRe-NAS - https://arxiv.org/abs/2102.11646
174184
* HRNet - https://arxiv.org/abs/1908.07919
175185
* Inception-V3 - https://arxiv.org/abs/1512.00567
176186
* Inception-ResNet-V2 and Inception-V4 - https://arxiv.org/abs/1602.07261

timm/models/layers/std_conv.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ class ScaledStdConv2d(nn.Conv2d):
7676

7777
def __init__(
7878
self, in_channels, out_channels, kernel_size, stride=1, padding=None, dilation=1, groups=1,
79-
bias=True, gamma=1.0, eps=1e-5, use_layernorm=False):
79+
bias=True, gamma=1.0, eps=1e-5, gain_init=1.0, use_layernorm=False):
8080
if padding is None:
8181
padding = get_padding(kernel_size, stride, dilation)
8282
super().__init__(
8383
in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation,
8484
groups=groups, bias=bias)
85-
self.gain = nn.Parameter(torch.ones(self.out_channels, 1, 1, 1))
85+
self.gain = nn.Parameter(torch.full((self.out_channels, 1, 1, 1), gain_init))
8686
self.scale = gamma * self.weight[0].numel() ** -0.5 # gamma * 1 / sqrt(fan-in)
8787
self.eps = eps ** 2 if use_layernorm else eps
8888
self.use_layernorm = use_layernorm # experimental, slightly faster/less GPU memory to hijack LN kernel
@@ -110,12 +110,12 @@ class ScaledStdConv2dSame(nn.Conv2d):
110110

111111
def __init__(
112112
self, in_channels, out_channels, kernel_size, stride=1, padding='SAME', dilation=1, groups=1,
113-
bias=True, gamma=1.0, eps=1e-5, use_layernorm=False):
113+
bias=True, gamma=1.0, eps=1e-5, gain_init=1.0, use_layernorm=False):
114114
padding, is_dynamic = get_padding_value(padding, kernel_size, stride=stride, dilation=dilation)
115115
super().__init__(
116116
in_channels, out_channels, kernel_size, stride=stride, padding=padding, dilation=dilation,
117117
groups=groups, bias=bias)
118-
self.gain = nn.Parameter(torch.ones(self.out_channels, 1, 1, 1))
118+
self.gain = nn.Parameter(torch.full((self.out_channels, 1, 1, 1), gain_init))
119119
self.scale = gamma * self.weight[0].numel() ** -0.5
120120
self.same_pad = is_dynamic
121121
self.eps = eps ** 2 if use_layernorm else eps

timm/models/nfnet.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def _dcfg(url='', **kwargs):
104104
url='', pool_size=(7, 7), input_size=(3, 224, 224), test_input_size=(3, 288, 288)),
105105
nfnet_l0b=_dcfg(
106106
url='', pool_size=(7, 7), input_size=(3, 224, 224), test_input_size=(3, 288, 288)),
107-
nfnet_l0c=_dcfg(
108-
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/nfnet_l0c-ad1045c2.pth',
107+
eca_nfnet_l0=_dcfg(
108+
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/ecanfnet_l0_ra2-e3e9ac50.pth',
109109
pool_size=(7, 7), input_size=(3, 224, 224), test_input_size=(3, 288, 288), crop_pct=1.0),
110110

111111
nf_regnet_b0=_dcfg(
@@ -238,7 +238,7 @@ def _dm_nfnet_cfg(depths, channels=(256, 512, 1536, 1536), act_layer='gelu', ski
238238
nfnet_l0b=_nfnet_cfg(
239239
depths=(1, 2, 6, 3), channels=(256, 512, 1536, 1536), feat_mult=1.5, group_size=64, bottle_ratio=0.25,
240240
attn_kwargs=dict(reduction_ratio=0.25, divisor=8), act_layer='silu'),
241-
nfnet_l0c=_nfnet_cfg(
241+
eca_nfnet_l0=_nfnet_cfg(
242242
depths=(1, 2, 6, 3), channels=(256, 512, 1536, 1536), feat_mult=1.5, group_size=64, bottle_ratio=0.25,
243243
attn_layer='eca', attn_kwargs=dict(), act_layer='silu'),
244244

@@ -343,7 +343,7 @@ def __init__(
343343
else:
344344
self.attn = None
345345
self.act3 = act_layer()
346-
self.conv3 = conv_layer(mid_chs, out_chs, 1)
346+
self.conv3 = conv_layer(mid_chs, out_chs, 1, gain_init=1. if skipinit else 0.)
347347
if not reg and attn_layer is not None:
348348
self.attn_last = attn_layer(out_chs) # ResNet blocks apply attn after conv3
349349
else:
@@ -804,11 +804,11 @@ def nfnet_l0b(pretrained=False, **kwargs):
804804

805805

806806
@register_model
807-
def nfnet_l0c(pretrained=False, **kwargs):
808-
""" NFNet-L0c w/ SiLU
807+
def eca_nfnet_l0(pretrained=False, **kwargs):
808+
""" ECA-NFNet-L0 w/ SiLU
809809
My experimental 'light' model w/ 1.5x final_conv mult, 64 group_size, .25 bottleneck & ECA attn
810810
"""
811-
return _create_normfreenet('nfnet_l0c', pretrained=pretrained, **kwargs)
811+
return _create_normfreenet('eca_nfnet_l0', pretrained=pretrained, **kwargs)
812812

813813

814814
@register_model

timm/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.4.5'
1+
__version__ = '0.4.6'

0 commit comments

Comments
 (0)