From 0968bdeca3187aa8b5d5729a35c5f4c2b27c7e74 Mon Sep 17 00:00:00 2001 From: talrid Date: Tue, 27 Apr 2021 20:54:06 +0300 Subject: [PATCH 1/6] vit, tresnet and mobilenetV3 ImageNet-21K-P weights --- timm/models/mobilenetv3.py | 20 +++++++++++++++++ timm/models/tresnet.py | 8 ++++++- timm/models/vision_transformer.py | 37 +++++++++++++++++++++++++++---- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/timm/models/mobilenetv3.py b/timm/models/mobilenetv3.py index 3ec1ab9b..1d5a7fc0 100644 --- a/timm/models/mobilenetv3.py +++ b/timm/models/mobilenetv3.py @@ -39,6 +39,12 @@ default_cfgs = { 'mobilenetv3_large_100': _cfg( interpolation='bicubic', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mobilenetv3_large_100_ra-f55367f5.pth'), + 'mobilenetv3_large_100_1k_miil_77_9': _cfg( + interpolation='bilinear', mean=(0, 0, 0), std=(1, 1, 1), + url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/mobilenetv3_large_100_1k_miil_77_9.pth'), + 'mobilenetv3_large_100_21k_miil': _cfg( + interpolation='bilinear', mean=(0, 0, 0), std=(1, 1, 1), + url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/mobilenetv3_large_100_21k_miil.pth', num_classes=11221), 'mobilenetv3_small_075': _cfg(url=''), 'mobilenetv3_small_100': _cfg(url=''), 'mobilenetv3_rw': _cfg( @@ -367,6 +373,20 @@ def mobilenetv3_large_100(pretrained=False, **kwargs): return model +@register_model +def mobilenetv3_large_100_1k_miil(pretrained=False, **kwargs): + """ MobileNet V3 """ + model = _gen_mobilenet_v3('mobilenetv3_large_100_1k_miil_77_9', 1.0, pretrained=pretrained, **kwargs) + return model + + +@register_model +def mobilenetv3_large_100_21k_miil(pretrained=False, **kwargs): + """ MobileNet V3 """ + model = _gen_mobilenet_v3('mobilenetv3_large_100_21k_miil', 1.0, pretrained=pretrained, **kwargs) + return model + + @register_model def mobilenetv3_small_075(pretrained=False, **kwargs): """ MobileNet V3 """ diff --git a/timm/models/tresnet.py b/timm/models/tresnet.py index a8c237ed..27cdc6cc 100644 --- a/timm/models/tresnet.py +++ b/timm/models/tresnet.py @@ -32,7 +32,9 @@ def _cfg(url='', **kwargs): default_cfgs = { 'tresnet_m': _cfg( - url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tresnet/tresnet_m_80_8-dbc13962.pth'), + url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/tresnet_m_1k_miil_83_1.pth'), + 'tresnet_m_21k_miil': _cfg( + url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/tresnet_m_miil_21k.pth', num_classes=11221), 'tresnet_l': _cfg( url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tresnet/tresnet_l_81_5-235b486c.pth'), 'tresnet_xl': _cfg( @@ -264,6 +266,10 @@ def tresnet_m(pretrained=False, **kwargs): model_kwargs = dict(layers=[3, 4, 11, 3], **kwargs) return _create_tresnet('tresnet_m', pretrained=pretrained, **model_kwargs) +@register_model +def tresnet_m_21k_miil(pretrained=False, **kwargs): + model_kwargs = dict(layers=[3, 4, 11, 3], **kwargs) + return _create_tresnet('tresnet_m_21k_miil', pretrained=pretrained, **model_kwargs) @register_model def tresnet_l(pretrained=False, **kwargs): diff --git a/timm/models/vision_transformer.py b/timm/models/vision_transformer.py index f57242a1..ae73d1d8 100644 --- a/timm/models/vision_transformer.py +++ b/timm/models/vision_transformer.py @@ -118,6 +118,17 @@ default_cfgs = { 'vit_deit_base_distilled_patch16_384': _cfg( url='https://dl.fbaipublicfiles.com/deit/deit_base_distilled_patch16_384-d0272ac0.pth', input_size=(3, 384, 384), crop_pct=1.0, classifier=('head', 'head_dist')), + + # ViT ImageNet-21K-P pretraining + 'vit_base_patch16_224_21k_miil': _cfg( + url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/vit_base_patch16_224_21k_miil.pth', + mean=(0, 0, 0), std=(1, 1, 1), crop_pct=0.875, interpolation='bilinear', num_classes=11221, + ), + 'vit_base_patch16_224_1k_miil': _cfg( + url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm' + '/vit_base_patch16_224_1k_miil_84_4.pth', + mean=(0, 0, 0), std=(1, 1, 1), crop_pct=0.875, interpolation='bilinear', + ), } @@ -155,7 +166,7 @@ class Attention(nn.Module): def forward(self, x): B, N, C = x.shape qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4) - q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple) + q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple) attn = (q @ k.transpose(-2, -1)) * self.scale attn = attn.softmax(dim=-1) @@ -652,7 +663,7 @@ def vit_deit_tiny_distilled_patch16_224(pretrained=False, **kwargs): """ model_kwargs = dict(patch_size=16, embed_dim=192, depth=12, num_heads=3, **kwargs) model = _create_vision_transformer( - 'vit_deit_tiny_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) + 'vit_deit_tiny_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) return model @@ -663,7 +674,7 @@ def vit_deit_small_distilled_patch16_224(pretrained=False, **kwargs): """ model_kwargs = dict(patch_size=16, embed_dim=384, depth=12, num_heads=6, **kwargs) model = _create_vision_transformer( - 'vit_deit_small_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) + 'vit_deit_small_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) return model @@ -674,7 +685,7 @@ def vit_deit_base_distilled_patch16_224(pretrained=False, **kwargs): """ model_kwargs = dict(patch_size=16, embed_dim=768, depth=12, num_heads=12, **kwargs) model = _create_vision_transformer( - 'vit_deit_base_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) + 'vit_deit_base_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) return model @@ -687,3 +698,21 @@ def vit_deit_base_distilled_patch16_384(pretrained=False, **kwargs): model = _create_vision_transformer( 'vit_deit_base_distilled_patch16_384', pretrained=pretrained, distilled=True, **model_kwargs) return model + +@register_model +def vit_base_patch16_224_21k_miil(pretrained=False, **kwargs): + """ ViT-Base (ViT-B/16) from original paper (https://arxiv.org/abs/2010.11929). + Weights taken from: https://github.com/Alibaba-MIIL/ImageNet21K + """ + model_kwargs = dict(patch_size=16, embed_dim=768, depth=12, num_heads=12, qkv_bias=False, **kwargs) + model = _create_vision_transformer('vit_base_patch16_224_21k_miil', pretrained=pretrained, **model_kwargs) + return model + +@register_model +def vit_base_patch16_224_1k_miil(pretrained=False, **kwargs): + """ ViT-Base (ViT-B/16) from original paper (https://arxiv.org/abs/2010.11929). + Weights taken from: https://github.com/Alibaba-MIIL/ImageNet21K + """ + model_kwargs = dict(patch_size=16, embed_dim=768, depth=12, num_heads=12, qkv_bias=False, **kwargs) + model = _create_vision_transformer('vit_base_patch16_224_1k_miil_84_4', pretrained=pretrained, **model_kwargs) + return model \ No newline at end of file From cf0e371594294685e02df4d1d51c00e0c2c916e9 Mon Sep 17 00:00:00 2001 From: talrid Date: Tue, 27 Apr 2021 22:33:55 +0300 Subject: [PATCH 2/6] 84_0 --- timm/models/vision_transformer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/timm/models/vision_transformer.py b/timm/models/vision_transformer.py index ae73d1d8..fde16abd 100644 --- a/timm/models/vision_transformer.py +++ b/timm/models/vision_transformer.py @@ -126,7 +126,7 @@ default_cfgs = { ), 'vit_base_patch16_224_1k_miil': _cfg( url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm' - '/vit_base_patch16_224_1k_miil_84_4.pth', + '/vit_base_patch16_224_1k_miil_84_0.pth', mean=(0, 0, 0), std=(1, 1, 1), crop_pct=0.875, interpolation='bilinear', ), } @@ -714,5 +714,5 @@ def vit_base_patch16_224_1k_miil(pretrained=False, **kwargs): Weights taken from: https://github.com/Alibaba-MIIL/ImageNet21K """ model_kwargs = dict(patch_size=16, embed_dim=768, depth=12, num_heads=12, qkv_bias=False, **kwargs) - model = _create_vision_transformer('vit_base_patch16_224_1k_miil_84_4', pretrained=pretrained, **model_kwargs) + model = _create_vision_transformer('vit_base_patch16_224_1k_miil', pretrained=pretrained, **model_kwargs) return model \ No newline at end of file From a443865876ea0ed4091fbc834a63198dc9bdc44b Mon Sep 17 00:00:00 2001 From: talrid Date: Wed, 28 Apr 2021 08:57:06 +0300 Subject: [PATCH 3/6] update naming and scores --- timm/models/mobilenetv3.py | 14 +++++++------- timm/models/tresnet.py | 8 ++++---- timm/models/vision_transformer.py | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/timm/models/mobilenetv3.py b/timm/models/mobilenetv3.py index 1d5a7fc0..84bce1a5 100644 --- a/timm/models/mobilenetv3.py +++ b/timm/models/mobilenetv3.py @@ -39,12 +39,12 @@ default_cfgs = { 'mobilenetv3_large_100': _cfg( interpolation='bicubic', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mobilenetv3_large_100_ra-f55367f5.pth'), - 'mobilenetv3_large_100_1k_miil_77_9': _cfg( + 'mobilenetv3_large_100_1k_miil_78_0': _cfg( interpolation='bilinear', mean=(0, 0, 0), std=(1, 1, 1), - url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/mobilenetv3_large_100_1k_miil_77_9.pth'), - 'mobilenetv3_large_100_21k_miil': _cfg( + url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/mobilenetv3_large_100_1k_miil_78_0.pth'), + 'mobilenetv3_large_100_in21k_miil': _cfg( interpolation='bilinear', mean=(0, 0, 0), std=(1, 1, 1), - url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/mobilenetv3_large_100_21k_miil.pth', num_classes=11221), + url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/mobilenetv3_large_100_in21k_miil.pth', num_classes=11221), 'mobilenetv3_small_075': _cfg(url=''), 'mobilenetv3_small_100': _cfg(url=''), 'mobilenetv3_rw': _cfg( @@ -376,14 +376,14 @@ def mobilenetv3_large_100(pretrained=False, **kwargs): @register_model def mobilenetv3_large_100_1k_miil(pretrained=False, **kwargs): """ MobileNet V3 """ - model = _gen_mobilenet_v3('mobilenetv3_large_100_1k_miil_77_9', 1.0, pretrained=pretrained, **kwargs) + model = _gen_mobilenet_v3('mobilenetv3_large_100_1k_miil_78_0', 1.0, pretrained=pretrained, **kwargs) return model @register_model -def mobilenetv3_large_100_21k_miil(pretrained=False, **kwargs): +def mobilenetv3_large_100_in21k_miil(pretrained=False, **kwargs): """ MobileNet V3 """ - model = _gen_mobilenet_v3('mobilenetv3_large_100_21k_miil', 1.0, pretrained=pretrained, **kwargs) + model = _gen_mobilenet_v3('mobilenetv3_large_100_in21k_miil', 1.0, pretrained=pretrained, **kwargs) return model diff --git a/timm/models/tresnet.py b/timm/models/tresnet.py index 27cdc6cc..20a9cc96 100644 --- a/timm/models/tresnet.py +++ b/timm/models/tresnet.py @@ -33,8 +33,8 @@ def _cfg(url='', **kwargs): default_cfgs = { 'tresnet_m': _cfg( url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/tresnet_m_1k_miil_83_1.pth'), - 'tresnet_m_21k_miil': _cfg( - url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/tresnet_m_miil_21k.pth', num_classes=11221), + 'tresnet_m_in21k_miil': _cfg( + url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/tresnet_m_miil_in21k.pth', num_classes=11221), 'tresnet_l': _cfg( url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tresnet/tresnet_l_81_5-235b486c.pth'), 'tresnet_xl': _cfg( @@ -267,9 +267,9 @@ def tresnet_m(pretrained=False, **kwargs): return _create_tresnet('tresnet_m', pretrained=pretrained, **model_kwargs) @register_model -def tresnet_m_21k_miil(pretrained=False, **kwargs): +def tresnet_m_in21k_miil(pretrained=False, **kwargs): model_kwargs = dict(layers=[3, 4, 11, 3], **kwargs) - return _create_tresnet('tresnet_m_21k_miil', pretrained=pretrained, **model_kwargs) + return _create_tresnet('tresnet_m_in21k_miil', pretrained=pretrained, **model_kwargs) @register_model def tresnet_l(pretrained=False, **kwargs): diff --git a/timm/models/vision_transformer.py b/timm/models/vision_transformer.py index fde16abd..fd990c85 100644 --- a/timm/models/vision_transformer.py +++ b/timm/models/vision_transformer.py @@ -120,13 +120,13 @@ default_cfgs = { input_size=(3, 384, 384), crop_pct=1.0, classifier=('head', 'head_dist')), # ViT ImageNet-21K-P pretraining - 'vit_base_patch16_224_21k_miil': _cfg( - url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/vit_base_patch16_224_21k_miil.pth', + 'vit_base_patch16_224_in21k_miil': _cfg( + url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/vit_base_patch16_224_in21k_miil.pth', mean=(0, 0, 0), std=(1, 1, 1), crop_pct=0.875, interpolation='bilinear', num_classes=11221, ), 'vit_base_patch16_224_1k_miil': _cfg( url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm' - '/vit_base_patch16_224_1k_miil_84_0.pth', + '/vit_base_patch16_224_1k_miil_84_4.pth', mean=(0, 0, 0), std=(1, 1, 1), crop_pct=0.875, interpolation='bilinear', ), } @@ -700,12 +700,12 @@ def vit_deit_base_distilled_patch16_384(pretrained=False, **kwargs): return model @register_model -def vit_base_patch16_224_21k_miil(pretrained=False, **kwargs): +def vit_base_patch16_224_in21k_miil(pretrained=False, **kwargs): """ ViT-Base (ViT-B/16) from original paper (https://arxiv.org/abs/2010.11929). Weights taken from: https://github.com/Alibaba-MIIL/ImageNet21K """ model_kwargs = dict(patch_size=16, embed_dim=768, depth=12, num_heads=12, qkv_bias=False, **kwargs) - model = _create_vision_transformer('vit_base_patch16_224_21k_miil', pretrained=pretrained, **model_kwargs) + model = _create_vision_transformer('vit_base_patch16_224_in21k_miil', pretrained=pretrained, **model_kwargs) return model @register_model From 19e1b67a84d94180a314d491d0b263b5bf2bacd8 Mon Sep 17 00:00:00 2001 From: talrid Date: Wed, 28 Apr 2021 09:01:29 +0300 Subject: [PATCH 4/6] old spaces --- timm/models/vision_transformer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/timm/models/vision_transformer.py b/timm/models/vision_transformer.py index fd990c85..e55a9ca3 100644 --- a/timm/models/vision_transformer.py +++ b/timm/models/vision_transformer.py @@ -166,7 +166,7 @@ class Attention(nn.Module): def forward(self, x): B, N, C = x.shape qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4) - q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple) + q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple) attn = (q @ k.transpose(-2, -1)) * self.scale attn = attn.softmax(dim=-1) @@ -663,7 +663,7 @@ def vit_deit_tiny_distilled_patch16_224(pretrained=False, **kwargs): """ model_kwargs = dict(patch_size=16, embed_dim=192, depth=12, num_heads=3, **kwargs) model = _create_vision_transformer( - 'vit_deit_tiny_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) + 'vit_deit_tiny_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) return model @@ -674,7 +674,7 @@ def vit_deit_small_distilled_patch16_224(pretrained=False, **kwargs): """ model_kwargs = dict(patch_size=16, embed_dim=384, depth=12, num_heads=6, **kwargs) model = _create_vision_transformer( - 'vit_deit_small_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) + 'vit_deit_small_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) return model @@ -685,7 +685,7 @@ def vit_deit_base_distilled_patch16_224(pretrained=False, **kwargs): """ model_kwargs = dict(patch_size=16, embed_dim=768, depth=12, num_heads=12, **kwargs) model = _create_vision_transformer( - 'vit_deit_base_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) + 'vit_deit_base_distilled_patch16_224', pretrained=pretrained, distilled=True, **model_kwargs) return model From 8c1f03e56cef6fceb1ad9307193ac4c5adf31014 Mon Sep 17 00:00:00 2001 From: talrid Date: Wed, 28 Apr 2021 09:04:10 +0300 Subject: [PATCH 5/6] comment --- timm/models/mobilenetv3.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/timm/models/mobilenetv3.py b/timm/models/mobilenetv3.py index 84bce1a5..42395388 100644 --- a/timm/models/mobilenetv3.py +++ b/timm/models/mobilenetv3.py @@ -375,14 +375,18 @@ def mobilenetv3_large_100(pretrained=False, **kwargs): @register_model def mobilenetv3_large_100_1k_miil(pretrained=False, **kwargs): - """ MobileNet V3 """ + """ MobileNet V3 + Weights taken from: https://github.com/Alibaba-MIIL/ImageNet21K + """ model = _gen_mobilenet_v3('mobilenetv3_large_100_1k_miil_78_0', 1.0, pretrained=pretrained, **kwargs) return model @register_model def mobilenetv3_large_100_in21k_miil(pretrained=False, **kwargs): - """ MobileNet V3 """ + """ MobileNet V3, 21k pretraining + Weights taken from: https://github.com/Alibaba-MIIL/ImageNet21K + """ model = _gen_mobilenet_v3('mobilenetv3_large_100_in21k_miil', 1.0, pretrained=pretrained, **kwargs) return model From a0492e3b48a27d988bf1dd92c471d7ae8fd50f5e Mon Sep 17 00:00:00 2001 From: Ross Wightman Date: Wed, 28 Apr 2021 10:33:02 -0700 Subject: [PATCH 6/6] A few miil weights naming tweaks to improve compat with model registry and filtering wildcards. --- timm/models/mobilenetv3.py | 12 ++++++------ timm/models/tresnet.py | 8 +++++--- timm/models/vision_transformer.py | 14 ++++++++------ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/timm/models/mobilenetv3.py b/timm/models/mobilenetv3.py index 42395388..543b33ea 100644 --- a/timm/models/mobilenetv3.py +++ b/timm/models/mobilenetv3.py @@ -39,10 +39,10 @@ default_cfgs = { 'mobilenetv3_large_100': _cfg( interpolation='bicubic', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mobilenetv3_large_100_ra-f55367f5.pth'), - 'mobilenetv3_large_100_1k_miil_78_0': _cfg( + 'mobilenetv3_large_100_miil': _cfg( interpolation='bilinear', mean=(0, 0, 0), std=(1, 1, 1), url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/mobilenetv3_large_100_1k_miil_78_0.pth'), - 'mobilenetv3_large_100_in21k_miil': _cfg( + 'mobilenetv3_large_100_miil_in21k': _cfg( interpolation='bilinear', mean=(0, 0, 0), std=(1, 1, 1), url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/mobilenetv3_large_100_in21k_miil.pth', num_classes=11221), 'mobilenetv3_small_075': _cfg(url=''), @@ -374,20 +374,20 @@ def mobilenetv3_large_100(pretrained=False, **kwargs): @register_model -def mobilenetv3_large_100_1k_miil(pretrained=False, **kwargs): +def mobilenetv3_large_100_miil(pretrained=False, **kwargs): """ MobileNet V3 Weights taken from: https://github.com/Alibaba-MIIL/ImageNet21K """ - model = _gen_mobilenet_v3('mobilenetv3_large_100_1k_miil_78_0', 1.0, pretrained=pretrained, **kwargs) + model = _gen_mobilenet_v3('mobilenetv3_large_100_miil', 1.0, pretrained=pretrained, **kwargs) return model @register_model -def mobilenetv3_large_100_in21k_miil(pretrained=False, **kwargs): +def mobilenetv3_large_100_miil_in21k(pretrained=False, **kwargs): """ MobileNet V3, 21k pretraining Weights taken from: https://github.com/Alibaba-MIIL/ImageNet21K """ - model = _gen_mobilenet_v3('mobilenetv3_large_100_in21k_miil', 1.0, pretrained=pretrained, **kwargs) + model = _gen_mobilenet_v3('mobilenetv3_large_100_miil_in21k', 1.0, pretrained=pretrained, **kwargs) return model diff --git a/timm/models/tresnet.py b/timm/models/tresnet.py index 20a9cc96..ee1f3fc1 100644 --- a/timm/models/tresnet.py +++ b/timm/models/tresnet.py @@ -33,7 +33,7 @@ def _cfg(url='', **kwargs): default_cfgs = { 'tresnet_m': _cfg( url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/tresnet_m_1k_miil_83_1.pth'), - 'tresnet_m_in21k_miil': _cfg( + 'tresnet_m_miil_in21k': _cfg( url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/tresnet_m_miil_in21k.pth', num_classes=11221), 'tresnet_l': _cfg( url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-tresnet/tresnet_l_81_5-235b486c.pth'), @@ -266,10 +266,12 @@ def tresnet_m(pretrained=False, **kwargs): model_kwargs = dict(layers=[3, 4, 11, 3], **kwargs) return _create_tresnet('tresnet_m', pretrained=pretrained, **model_kwargs) + @register_model -def tresnet_m_in21k_miil(pretrained=False, **kwargs): +def tresnet_m_miil_in21k(pretrained=False, **kwargs): model_kwargs = dict(layers=[3, 4, 11, 3], **kwargs) - return _create_tresnet('tresnet_m_in21k_miil', pretrained=pretrained, **model_kwargs) + return _create_tresnet('tresnet_m_miil_in21k', pretrained=pretrained, **model_kwargs) + @register_model def tresnet_l(pretrained=False, **kwargs): diff --git a/timm/models/vision_transformer.py b/timm/models/vision_transformer.py index e55a9ca3..4bf1dec5 100644 --- a/timm/models/vision_transformer.py +++ b/timm/models/vision_transformer.py @@ -120,11 +120,11 @@ default_cfgs = { input_size=(3, 384, 384), crop_pct=1.0, classifier=('head', 'head_dist')), # ViT ImageNet-21K-P pretraining - 'vit_base_patch16_224_in21k_miil': _cfg( + 'vit_base_patch16_224_miil_in21k': _cfg( url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm/vit_base_patch16_224_in21k_miil.pth', mean=(0, 0, 0), std=(1, 1, 1), crop_pct=0.875, interpolation='bilinear', num_classes=11221, ), - 'vit_base_patch16_224_1k_miil': _cfg( + 'vit_base_patch16_224_miil': _cfg( url='https://miil-public-eu.oss-eu-central-1.aliyuncs.com/model-zoo/ImageNet_21K_P/models/timm' '/vit_base_patch16_224_1k_miil_84_4.pth', mean=(0, 0, 0), std=(1, 1, 1), crop_pct=0.875, interpolation='bilinear', @@ -699,20 +699,22 @@ def vit_deit_base_distilled_patch16_384(pretrained=False, **kwargs): 'vit_deit_base_distilled_patch16_384', pretrained=pretrained, distilled=True, **model_kwargs) return model + @register_model -def vit_base_patch16_224_in21k_miil(pretrained=False, **kwargs): +def vit_base_patch16_224_miil_in21k(pretrained=False, **kwargs): """ ViT-Base (ViT-B/16) from original paper (https://arxiv.org/abs/2010.11929). Weights taken from: https://github.com/Alibaba-MIIL/ImageNet21K """ model_kwargs = dict(patch_size=16, embed_dim=768, depth=12, num_heads=12, qkv_bias=False, **kwargs) - model = _create_vision_transformer('vit_base_patch16_224_in21k_miil', pretrained=pretrained, **model_kwargs) + model = _create_vision_transformer('vit_base_patch16_224_miil_in21k', pretrained=pretrained, **model_kwargs) return model + @register_model -def vit_base_patch16_224_1k_miil(pretrained=False, **kwargs): +def vit_base_patch16_224_miil(pretrained=False, **kwargs): """ ViT-Base (ViT-B/16) from original paper (https://arxiv.org/abs/2010.11929). Weights taken from: https://github.com/Alibaba-MIIL/ImageNet21K """ model_kwargs = dict(patch_size=16, embed_dim=768, depth=12, num_heads=12, qkv_bias=False, **kwargs) - model = _create_vision_transformer('vit_base_patch16_224_1k_miil', pretrained=pretrained, **model_kwargs) + model = _create_vision_transformer('vit_base_patch16_224_miil', pretrained=pretrained, **model_kwargs) return model \ No newline at end of file