@@ -187,6 +187,9 @@ def _cfg(url='', **kwargs):
187187 'efficientnetv2_l' : _cfg (
188188 url = '' ,
189189 input_size = (3 , 384 , 384 ), test_input_size = (3 , 480 , 480 ), pool_size = (12 , 12 ), crop_pct = 1.0 ),
190+ 'efficientnetv2_xl' : _cfg (
191+ url = '' ,
192+ input_size = (3 , 384 , 384 ), test_input_size = (3 , 512 , 512 ), pool_size = (12 , 12 ), crop_pct = 1.0 ),
190193
191194 'tf_efficientnet_b0' : _cfg (
192195 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b0_aa-827b6e33.pth' ,
@@ -358,6 +361,10 @@ def _cfg(url='', **kwargs):
358361 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-effv2-weights/tf_efficientnetv2_l_21ft1k-60127a9d.pth' ,
359362 mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ),
360363 input_size = (3 , 384 , 384 ), test_input_size = (3 , 480 , 480 ), pool_size = (12 , 12 ), crop_pct = 1.0 ),
364+ 'tf_efficientnetv2_xl_in21ft1k' : _cfg (
365+ url = '' ,
366+ mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ),
367+ input_size = (3 , 384 , 384 ), test_input_size = (3 , 512 , 512 ), pool_size = (12 , 12 ), crop_pct = 1.0 ),
361368
362369 'tf_efficientnetv2_s_in21k' : _cfg (
363370 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-effv2-weights/tf_efficientnetv2_s_21k-6337ad01.pth' ,
@@ -371,6 +378,10 @@ def _cfg(url='', **kwargs):
371378 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-effv2-weights/tf_efficientnetv2_l_21k-91a19ec9.pth' ,
372379 mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ), num_classes = 21843 ,
373380 input_size = (3 , 384 , 384 ), test_input_size = (3 , 480 , 480 ), pool_size = (12 , 12 ), crop_pct = 1.0 ),
381+ 'tf_efficientnetv2_xl_in21k' : _cfg (
382+ url = '' ,
383+ mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ), num_classes = 21843 ,
384+ input_size = (3 , 384 , 384 ), test_input_size = (3 , 512 , 512 ), pool_size = (12 , 12 ), crop_pct = 1.0 ),
374385
375386 'tf_efficientnetv2_b0' : _cfg (
376387 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-effv2-weights/tf_efficientnetv2_b0-c7cc451f.pth' ,
@@ -408,7 +419,7 @@ class EfficientNet(nn.Module):
408419 """ (Generic) EfficientNet
409420
410421 A flexible and performant PyTorch implementation of efficient network architectures, including:
411- * EfficientNet-V2 Small, Medium, Large & B0-B3
422+ * EfficientNet-V2 Small, Medium, Large, XL & B0-B3
412423 * EfficientNet B0-B8, L2
413424 * EfficientNet-EdgeTPU
414425 * EfficientNet-CondConv
@@ -1038,6 +1049,36 @@ def _gen_efficientnetv2_l(variant, channel_multiplier=1.0, depth_multiplier=1.0,
10381049 return model
10391050
10401051
1052+ def _gen_efficientnetv2_xl (variant , channel_multiplier = 1.0 , depth_multiplier = 1.0 , pretrained = False , ** kwargs ):
1053+ """ Creates an EfficientNet-V2 Xtra-Large model
1054+
1055+ Ref impl: https://github.com/google/automl/tree/master/efficientnetv2
1056+ Paper: `EfficientNetV2: Smaller Models and Faster Training` - https://arxiv.org/abs/2104.00298
1057+ """
1058+
1059+ arch_def = [
1060+ ['cn_r4_k3_s1_e1_c32_skip' ],
1061+ ['er_r8_k3_s2_e4_c64' ],
1062+ ['er_r8_k3_s2_e4_c96' ],
1063+ ['ir_r16_k3_s2_e4_c192_se0.25' ],
1064+ ['ir_r24_k3_s1_e6_c256_se0.25' ],
1065+ ['ir_r32_k3_s2_e6_c512_se0.25' ],
1066+ ['ir_r8_k3_s1_e6_c640_se0.25' ],
1067+ ]
1068+
1069+ model_kwargs = dict (
1070+ block_args = decode_arch_def (arch_def , depth_multiplier ),
1071+ num_features = 1280 ,
1072+ stem_size = 32 ,
1073+ round_chs_fn = partial (round_channels , multiplier = channel_multiplier ),
1074+ norm_layer = partial (nn .BatchNorm2d , ** resolve_bn_args (kwargs )),
1075+ act_layer = resolve_act_layer (kwargs , 'silu' ),
1076+ ** kwargs ,
1077+ )
1078+ model = _create_effnet (variant , pretrained , ** model_kwargs )
1079+ return model
1080+
1081+
10411082def _gen_mixnet_s (variant , channel_multiplier = 1.0 , pretrained = False , ** kwargs ):
10421083 """Creates a MixNet Small model.
10431084
@@ -1551,6 +1592,13 @@ def efficientnetv2_l(pretrained=False, **kwargs):
15511592 return model
15521593
15531594
1595+ @register_model
1596+ def efficientnetv2_xl (pretrained = False , ** kwargs ):
1597+ """ EfficientNet-V2 Xtra-Large. """
1598+ model = _gen_efficientnetv2_xl ('efficientnetv2_xl' , pretrained = pretrained , ** kwargs )
1599+ return model
1600+
1601+
15541602@register_model
15551603def tf_efficientnet_b0 (pretrained = False , ** kwargs ):
15561604 """ EfficientNet-B0. Tensorflow compatible variant """
@@ -2019,6 +2067,16 @@ def tf_efficientnetv2_l_in21ft1k(pretrained=False, **kwargs):
20192067 return model
20202068
20212069
2070+ @register_model
2071+ def tf_efficientnetv2_xl_in21ft1k (pretrained = False , ** kwargs ):
2072+ """ EfficientNet-V2 Xtra-Large. Pretrained on ImageNet-21k, fine-tuned on 1k. Tensorflow compatible variant
2073+ """
2074+ kwargs ['bn_eps' ] = BN_EPS_TF_DEFAULT
2075+ kwargs ['pad_type' ] = 'same'
2076+ model = _gen_efficientnetv2_xl ('tf_efficientnetv2_xl_in21ft1k' , pretrained = pretrained , ** kwargs )
2077+ return model
2078+
2079+
20222080@register_model
20232081def tf_efficientnetv2_s_in21k (pretrained = False , ** kwargs ):
20242082 """ EfficientNet-V2 Small w/ ImageNet-21k pretrained weights. Tensorflow compatible variant
@@ -2049,6 +2107,16 @@ def tf_efficientnetv2_l_in21k(pretrained=False, **kwargs):
20492107 return model
20502108
20512109
2110+ @register_model
2111+ def tf_efficientnetv2_xl_in21k (pretrained = False , ** kwargs ):
2112+ """ EfficientNet-V2 Xtra-Large w/ ImageNet-21k pretrained weights. Tensorflow compatible variant
2113+ """
2114+ kwargs ['bn_eps' ] = BN_EPS_TF_DEFAULT
2115+ kwargs ['pad_type' ] = 'same'
2116+ model = _gen_efficientnetv2_xl ('tf_efficientnetv2_xl_in21k' , pretrained = pretrained , ** kwargs )
2117+ return model
2118+
2119+
20522120@register_model
20532121def tf_efficientnetv2_b0 (pretrained = False , ** kwargs ):
20542122 """ EfficientNet-V2-B0. Tensorflow compatible variant """
0 commit comments