Skip to content

Commit 8470eb1

Browse files
committed
More fastvit & mobileone updates, ready for weight upload
1 parent 8474508 commit 8470eb1

File tree

3 files changed

+180
-167
lines changed

3 files changed

+180
-167
lines changed

timm/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from .efficientvit_mit import *
2121
from .efficientvit_msra import *
2222
from .eva import *
23+
from .fastvit import *
2324
from .focalnet import *
2425
from .gcvit import *
2526
from .ghostnet import *

timm/models/byobnet.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def __init__(
589589
self.identity = layers.norm_act(out_chs, apply_act=False) if use_ident else None
590590

591591
# Re-parameterizable conv branches
592-
convs = list()
592+
convs = []
593593
for _ in range(self.num_conv_branches):
594594
convs.append(layers.conv_norm_act(
595595
in_chs, out_chs, kernel_size=kernel_size,
@@ -624,8 +624,8 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
624624

625625
# Other branches
626626
out = scale_out + identity_out
627-
for ix in range(self.num_conv_branches):
628-
out += self.conv_kxk[ix](x)
627+
for ck in self.conv_kxk:
628+
out += ck(x)
629629

630630
return self.act(self.attn(out))
631631

@@ -1643,11 +1643,15 @@ def _init_weights(module, name='', zero_init_last=False):
16431643
),
16441644
)
16451645

1646+
# FIXME temporary for mobileone remap
1647+
from .fastvit import checkpoint_filter_fn
1648+
16461649

16471650
def _create_byobnet(variant, pretrained=False, **kwargs):
16481651
return build_model_with_cfg(
16491652
ByobNet, variant, pretrained,
16501653
model_cfg=model_cfgs[variant],
1654+
pretrained_filter_fn=checkpoint_filter_fn,
16511655
feature_cfg=dict(flatten_sequential=True),
16521656
**kwargs)
16531657

@@ -1805,6 +1809,27 @@ def _cfgr(url='', **kwargs):
18051809
hf_hub_id='timm/',
18061810
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tpu-weights/regnetz_d8_evos_ch-2bc12646.pth',
18071811
mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5), crop_pct=0.95, test_input_size=(3, 320, 320), test_crop_pct=1.0),
1812+
1813+
'mobileone_s0': _cfg(
1814+
url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileone/mobileone_s0_unfused.pth.tar',
1815+
crop_pct=0.875,
1816+
),
1817+
'mobileone_s1': _cfg(
1818+
url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileone/mobileone_s1_unfused.pth.tar',
1819+
crop_pct=0.9,
1820+
),
1821+
'mobileone_s2': _cfg(
1822+
url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileone/mobileone_s2_unfused.pth.tar',
1823+
crop_pct=0.9,
1824+
),
1825+
'mobileone_s3': _cfg(
1826+
url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileone/mobileone_s3_unfused.pth.tar',
1827+
crop_pct=0.9,
1828+
),
1829+
'mobileone_s4': _cfg(
1830+
url='https://docs-assets.developer.apple.com/ml-research/datasets/mobileone/mobileone_s4_unfused.pth.tar',
1831+
crop_pct=0.9,
1832+
),
18081833
})
18091834

18101835

0 commit comments

Comments
 (0)