Skip to content

Commit a7f9581

Browse files
authored
Merge pull request #413 from rwightman/eca-weights
Add new weights for ecaresnet26t/50t/269d models.
2 parents 3a7aa95 + a39c3ee commit a7f9581

File tree

8 files changed

+107
-132
lines changed

8 files changed

+107
-132
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## What's New
44

5+
### Feb 8, 2021
6+
* Add several ResNet weights with ECA attention. 26t & 50t trained @ 256, test @ 320. 269d train @ 256, fine-tune @320, test @ 352.
7+
* `ecaresnet26t` - 79.88 top-1 @ 320x320, 79.08 @ 256x256
8+
* `ecaresnet50t` - 82.35 top-1 @ 320x320, 81.52 @ 256x256
9+
* `ecaresnet269d` - 84.93 top-1 @ 352x352, 84.87 @ 320x320
10+
* Remove separate tiered (`t`) vs tiered_narrow (`tn`) ResNet model defs, all `tn` changed to `t` and `t` models removed (`seresnext26t_32x4d` only model w/ weights that was removed).
11+
* Support model default_cfgs with separate train vs test resolution `test_input_size`
12+
513
### Jan 30, 2021
614
* Add initial "Normalization Free" NF-RegNet-B* and NF-ResNet model definitions based on [paper](https://arxiv.org/abs/2101.08692)
715

sotabench.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ def _entry(model_name, paper_model_name, paper_arxiv_id, batch_size=BATCH_SIZE,
122122
model_desc='Block cfg of SE-ResNeXt-34 w/ Bottleneck, deep stem, and avg-pool in downsample layers.'),
123123
_entry('seresnext26t_32x4d', 'SE-ResNeXt-26-T 32x4d', '1812.01187',
124124
model_desc='Block cfg of SE-ResNeXt-34 w/ Bottleneck, deep tiered stem, and avg-pool in downsample layers.'),
125-
_entry('seresnext26tn_32x4d', 'SE-ResNeXt-26-TN 32x4d', '1812.01187',
126-
model_desc='Block cfg of SE-ResNeXt-34 w/ Bottleneck, deep tiered narrow stem, and avg-pool in downsample layers.'),
127125
_entry('seresnext50_32x4d', 'SE-ResNeXt-50 32x4d', '1709.01507'),
128126

129127
_entry('skresnet18', 'SK-ResNet-18', '1903.06586'),

timm/data/config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
_logger = logging.getLogger(__name__)
66

77

8-
def resolve_data_config(args, default_cfg={}, model=None, verbose=True):
8+
def resolve_data_config(args, default_cfg={}, model=None, use_test_size=False, verbose=True):
99
new_config = {}
1010
default_cfg = default_cfg
1111
if not default_cfg and model is not None and hasattr(model, 'default_cfg'):
@@ -25,8 +25,11 @@ def resolve_data_config(args, default_cfg={}, model=None, verbose=True):
2525
elif 'img_size' in args and args['img_size'] is not None:
2626
assert isinstance(args['img_size'], int)
2727
input_size = (in_chans, args['img_size'], args['img_size'])
28-
elif 'input_size' in default_cfg:
29-
input_size = default_cfg['input_size']
28+
else:
29+
if use_test_size and 'test_input_size' in default_cfg:
30+
input_size = default_cfg['test_input_size']
31+
elif 'input_size' in default_cfg:
32+
input_size = default_cfg['input_size']
3033
new_config['input_size'] = input_size
3134

3235
# resolve interpolation method

timm/models/efficientnet_blocks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ def __init__(self, in_chs, out_chs, exp_kernel_size=3, exp_ratio=1.0, fake_in_ch
350350
self.drop_path_rate = drop_path_rate
351351

352352
# Expansion convolution
353-
self.conv_exp = create_conv2d(in_chs, mid_chs, exp_kernel_size, padding=pad_type)
353+
self.conv_exp = create_conv2d(
354+
in_chs, mid_chs, exp_kernel_size, stride=stride, dilation=dilation, padding=pad_type)
354355
self.bn1 = norm_layer(mid_chs, **norm_kwargs)
355356
self.act1 = act_layer(inplace=True)
356357

@@ -362,8 +363,7 @@ def __init__(self, in_chs, out_chs, exp_kernel_size=3, exp_ratio=1.0, fake_in_ch
362363
self.se = None
363364

364365
# Point-wise linear projection
365-
self.conv_pwl = create_conv2d(
366-
mid_chs, out_chs, pw_kernel_size, stride=stride, dilation=dilation, padding=pad_type)
366+
self.conv_pwl = create_conv2d(mid_chs, out_chs, pw_kernel_size, padding=pad_type)
367367
self.bn2 = norm_layer(out_chs, **norm_kwargs)
368368

369369
def feature_info(self, location):

timm/models/layers/test_time_pool.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ def forward(self, x):
3636
return x.view(x.size(0), -1)
3737

3838

39-
def apply_test_time_pool(model, config):
39+
def apply_test_time_pool(model, config, use_test_size=True):
4040
test_time_pool = False
4141
if not hasattr(model, 'default_cfg') or not model.default_cfg:
4242
return model, False
43-
if (config['input_size'][-1] > model.default_cfg['input_size'][-1] and
44-
config['input_size'][-2] > model.default_cfg['input_size'][-2]):
43+
if use_test_size and 'test_input_size' in model.default_cfg:
44+
df_input_size = model.default_cfg['test_input_size']
45+
else:
46+
df_input_size = model.default_cfg['input_size']
47+
if config['input_size'][-1] > df_input_size[-1] and config['input_size'][-2] > df_input_size[-2]:
4548
_logger.info('Target input size %s > pretrained default %s, using test time pooling' %
46-
(str(config['input_size'][-2:]), str(model.default_cfg['input_size'][-2:])))
49+
(str(config['input_size'][-2:]), str(df_input_size[-2:])))
4750
model = TestTimePoolHead(model, original_pool=model.default_cfg['pool_size'])
4851
test_time_pool = True
4952
return model, test_time_pool

0 commit comments

Comments
 (0)