@@ -52,19 +52,22 @@ def _cfg(url='', **kwargs):
5252 'mnasnet_100' : _cfg (
5353 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mnasnet_b1-74cb7081.pth' ),
5454 'mnasnet_140' : _cfg (url = '' ),
55+
5556 'semnasnet_050' : _cfg (url = '' ),
5657 'semnasnet_075' : _cfg (url = '' ),
5758 'semnasnet_100' : _cfg (
5859 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mnasnet_a1-d9418771.pth' ),
5960 'semnasnet_140' : _cfg (url = '' ),
6061 'mnasnet_small' : _cfg (url = '' ),
62+
6163 'mobilenetv2_100' : _cfg (url = '' ),
6264 'fbnetc_100' : _cfg (
6365 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/fbnetc_100-c345b898.pth' ,
6466 interpolation = 'bilinear' ),
6567 'spnasnet_100' : _cfg (
6668 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/spnasnet_100-048bc3f4.pth' ,
6769 interpolation = 'bilinear' ),
70+
6871 'efficientnet_b0' : _cfg (
6972 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/efficientnet_b0_ra-3dd342df.pth' ),
7073 'efficientnet_b1' : _cfg (
@@ -94,15 +97,32 @@ def _cfg(url='', **kwargs):
9497 url = '' , input_size = (3 , 672 , 672 ), pool_size = (21 , 21 ), crop_pct = 0.954 ),
9598 'efficientnet_l2' : _cfg (
9699 url = '' , input_size = (3 , 800 , 800 ), pool_size = (25 , 25 ), crop_pct = 0.961 ),
100+
97101 'efficientnet_es' : _cfg (
98102 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/efficientnet_es_ra-f111e99c.pth' ),
99103 'efficientnet_em' : _cfg (
100104 url = '' , input_size = (3 , 240 , 240 ), pool_size = (8 , 8 ), crop_pct = 0.882 ),
101105 'efficientnet_el' : _cfg (
102106 url = '' , input_size = (3 , 300 , 300 ), pool_size = (10 , 10 ), crop_pct = 0.904 ),
107+
103108 'efficientnet_cc_b0_4e' : _cfg (url = '' ),
104109 'efficientnet_cc_b0_8e' : _cfg (url = '' ),
105110 'efficientnet_cc_b1_8e' : _cfg (url = '' , input_size = (3 , 240 , 240 ), pool_size = (8 , 8 ), crop_pct = 0.882 ),
111+
112+ 'efficientnet_lite0' : _cfg (
113+ url = '' ),
114+ 'efficientnet_lite1' : _cfg (
115+ url = '' ,
116+ input_size = (3 , 240 , 240 ), pool_size = (8 , 8 ), crop_pct = 0.882 ),
117+ 'efficientnet_lite2' : _cfg (
118+ url = '' ,
119+ input_size = (3 , 260 , 260 ), pool_size = (9 , 9 ), crop_pct = 0.890 ),
120+ 'efficientnet_lite3' : _cfg (
121+ url = '' ,
122+ input_size = (3 , 300 , 300 ), pool_size = (10 , 10 ), crop_pct = 0.904 ),
123+ 'efficientnet_lite4' : _cfg (
124+ url = '' , input_size = (3 , 380 , 380 ), pool_size = (12 , 12 ), crop_pct = 0.922 ),
125+
106126 'tf_efficientnet_b0' : _cfg (
107127 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b0_aa-827b6e33.pth' ,
108128 input_size = (3 , 224 , 224 )),
@@ -130,6 +150,7 @@ def _cfg(url='', **kwargs):
130150 'tf_efficientnet_b8' : _cfg (
131151 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b8_ra-572d5dd9.pth' ,
132152 input_size = (3 , 672 , 672 ), pool_size = (21 , 21 ), crop_pct = 0.954 ),
153+
133154 'tf_efficientnet_b0_ap' : _cfg (
134155 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b0_ap-f262efe1.pth' ,
135156 mean = IMAGENET_INCEPTION_MEAN , std = IMAGENET_INCEPTION_STD , input_size = (3 , 224 , 224 )),
@@ -165,6 +186,7 @@ def _cfg(url='', **kwargs):
165186 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b8_ap-00e169fa.pth' ,
166187 mean = IMAGENET_INCEPTION_MEAN , std = IMAGENET_INCEPTION_STD ,
167188 input_size = (3 , 672 , 672 ), pool_size = (21 , 21 ), crop_pct = 0.954 ),
189+
168190 'tf_efficientnet_b0_ns' : _cfg (
169191 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b0_ns-c0e6a31c.pth' ,
170192 input_size = (3 , 224 , 224 )),
@@ -195,6 +217,7 @@ def _cfg(url='', **kwargs):
195217 'tf_efficientnet_l2_ns' : _cfg (
196218 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_l2_ns-df73bb44.pth' ,
197219 input_size = (3 , 800 , 800 ), pool_size = (25 , 25 ), crop_pct = 0.96 ),
220+
198221 'tf_efficientnet_es' : _cfg (
199222 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_es-ca1afbfe.pth' ,
200223 mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ),
@@ -207,6 +230,7 @@ def _cfg(url='', **kwargs):
207230 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_el-5143854e.pth' ,
208231 mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ),
209232 input_size = (3 , 300 , 300 ), pool_size = (10 , 10 ), crop_pct = 0.904 ),
233+
210234 'tf_efficientnet_cc_b0_4e' : _cfg (
211235 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_cc_b0_4e-4362b6b2.pth' ,
212236 mean = IMAGENET_INCEPTION_MEAN , std = IMAGENET_INCEPTION_STD ),
@@ -217,6 +241,33 @@ def _cfg(url='', **kwargs):
217241 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_cc_b1_8e-f7c79ae1.pth' ,
218242 mean = IMAGENET_INCEPTION_MEAN , std = IMAGENET_INCEPTION_STD ,
219243 input_size = (3 , 240 , 240 ), pool_size = (8 , 8 ), crop_pct = 0.882 ),
244+
245+ 'tf_efficientnet_lite0' : _cfg (
246+ url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_lite0-0aa007d2.pth' ,
247+ mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ),
248+ interpolation = 'bicubic' , # should be bilinear but bicubic better match for TF bilinear at low res
249+ ),
250+ 'tf_efficientnet_lite1' : _cfg (
251+ url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_lite1-bde8b488.pth' ,
252+ mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ),
253+ input_size = (3 , 240 , 240 ), pool_size = (8 , 8 ), crop_pct = 0.882 ,
254+ interpolation = 'bicubic' , # should be bilinear but bicubic better match for TF bilinear at low res
255+ ),
256+ 'tf_efficientnet_lite2' : _cfg (
257+ url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_lite2-dcccb7df.pth' ,
258+ mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ),
259+ input_size = (3 , 260 , 260 ), pool_size = (9 , 9 ), crop_pct = 0.890 ,
260+ interpolation = 'bicubic' , # should be bilinear but bicubic better match for TF bilinear at low res
261+ ),
262+ 'tf_efficientnet_lite3' : _cfg (
263+ url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_lite3-b733e338.pth' ,
264+ mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ),
265+ input_size = (3 , 300 , 300 ), pool_size = (10 , 10 ), crop_pct = 0.904 , interpolation = 'bilinear' ),
266+ 'tf_efficientnet_lite4' : _cfg (
267+ url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_lite4-741542c3.pth' ,
268+ mean = (0.5 , 0.5 , 0.5 ), std = (0.5 , 0.5 , 0.5 ),
269+ input_size = (3 , 380 , 380 ), pool_size = (12 , 12 ), crop_pct = 0.922 , interpolation = 'bilinear' ),
270+
220271 'mixnet_s' : _cfg (
221272 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mixnet_s-a907afbc.pth' ),
222273 'mixnet_m' : _cfg (
@@ -226,6 +277,7 @@ def _cfg(url='', **kwargs):
226277 'mixnet_xl' : _cfg (
227278 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mixnet_xl_ra-aac3c00c.pth' ),
228279 'mixnet_xxl' : _cfg (),
280+
229281 'tf_mixnet_s' : _cfg (
230282 url = 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_mixnet_s-89d3354b.pth' ),
231283 'tf_mixnet_m' : _cfg (
@@ -253,7 +305,7 @@ class EfficientNet(nn.Module):
253305
254306 def __init__ (self , block_args , num_classes = 1000 , num_features = 1280 , in_chans = 3 , stem_size = 32 ,
255307 channel_multiplier = 1.0 , channel_divisor = 8 , channel_min = None ,
256- output_stride = 32 , pad_type = '' , act_layer = nn .ReLU , drop_rate = 0. , drop_path_rate = 0. ,
308+ output_stride = 32 , pad_type = '' , fix_stem = False , act_layer = nn .ReLU , drop_rate = 0. , drop_path_rate = 0. ,
257309 se_kwargs = None , norm_layer = nn .BatchNorm2d , norm_kwargs = None , global_pool = 'avg' ):
258310 super (EfficientNet , self ).__init__ ()
259311 norm_kwargs = norm_kwargs or {}
@@ -264,7 +316,8 @@ def __init__(self, block_args, num_classes=1000, num_features=1280, in_chans=3,
264316 self ._in_chs = in_chans
265317
266318 # Stem
267- stem_size = round_channels (stem_size , channel_multiplier , channel_divisor , channel_min )
319+ if not fix_stem :
320+ stem_size = round_channels (stem_size , channel_multiplier , channel_divisor , channel_min )
268321 self .conv_stem = create_conv2d (self ._in_chs , stem_size , 3 , stride = 2 , padding = pad_type )
269322 self .bn1 = norm_layer (stem_size , ** norm_kwargs )
270323 self .act1 = act_layer (inplace = True )
@@ -333,7 +386,7 @@ class EfficientNetFeatures(nn.Module):
333386
334387 def __init__ (self , block_args , out_indices = (0 , 1 , 2 , 3 , 4 ), feature_location = 'pre_pwl' ,
335388 in_chans = 3 , stem_size = 32 , channel_multiplier = 1.0 , channel_divisor = 8 , channel_min = None ,
336- output_stride = 32 , pad_type = '' , act_layer = nn .ReLU , drop_rate = 0. , drop_path_rate = 0. ,
389+ output_stride = 32 , pad_type = '' , fix_stem = False , act_layer = nn .ReLU , drop_rate = 0. , drop_path_rate = 0. ,
337390 se_kwargs = None , norm_layer = nn .BatchNorm2d , norm_kwargs = None ):
338391 super (EfficientNetFeatures , self ).__init__ ()
339392 norm_kwargs = norm_kwargs or {}
@@ -346,7 +399,8 @@ def __init__(self, block_args, out_indices=(0, 1, 2, 3, 4), feature_location='pr
346399 self ._in_chs = in_chans
347400
348401 # Stem
349- stem_size = round_channels (stem_size , channel_multiplier , channel_divisor , channel_min )
402+ if not fix_stem :
403+ stem_size = round_channels (stem_size , channel_multiplier , channel_divisor , channel_min )
350404 self .conv_stem = create_conv2d (self ._in_chs , stem_size , 3 , stride = 2 , padding = pad_type )
351405 self .bn1 = norm_layer (stem_size , ** norm_kwargs )
352406 self .act1 = act_layer (inplace = True )
@@ -707,6 +761,47 @@ def _gen_efficientnet_condconv(
707761 return model
708762
709763
764+ def _gen_efficientnet_lite (variant , channel_multiplier = 1.0 , depth_multiplier = 1.0 , pretrained = False , ** kwargs ):
765+ """Creates an EfficientNet-Lite model.
766+
767+ Ref impl: https://github.com/tensorflow/tpu/tree/master/models/official/efficientnet/lite
768+ Paper: https://arxiv.org/abs/1905.11946
769+
770+ EfficientNet params
771+ name: (channel_multiplier, depth_multiplier, resolution, dropout_rate)
772+ 'efficientnet-lite0': (1.0, 1.0, 224, 0.2),
773+ 'efficientnet-lite1': (1.0, 1.1, 240, 0.2),
774+ 'efficientnet-lite2': (1.1, 1.2, 260, 0.3),
775+ 'efficientnet-lite3': (1.2, 1.4, 280, 0.3),
776+ 'efficientnet-lite4': (1.4, 1.8, 300, 0.3),
777+
778+ Args:
779+ channel_multiplier: multiplier to number of channels per layer
780+ depth_multiplier: multiplier to number of repeats per stage
781+ """
782+ arch_def = [
783+ ['ds_r1_k3_s1_e1_c16' ],
784+ ['ir_r2_k3_s2_e6_c24' ],
785+ ['ir_r2_k5_s2_e6_c40' ],
786+ ['ir_r3_k3_s2_e6_c80' ],
787+ ['ir_r3_k5_s1_e6_c112' ],
788+ ['ir_r4_k5_s2_e6_c192' ],
789+ ['ir_r1_k3_s1_e6_c320' ],
790+ ]
791+ model_kwargs = dict (
792+ block_args = decode_arch_def (arch_def , depth_multiplier , fix_first_last = True ),
793+ num_features = 1280 ,
794+ stem_size = 32 ,
795+ fix_stem = True ,
796+ channel_multiplier = channel_multiplier ,
797+ act_layer = nn .ReLU6 ,
798+ norm_kwargs = resolve_bn_args (kwargs ),
799+ ** kwargs ,
800+ )
801+ model = _create_model (model_kwargs , default_cfgs [variant ], pretrained )
802+ return model
803+
804+
710805def _gen_mixnet_s (variant , channel_multiplier = 1.0 , pretrained = False , ** kwargs ):
711806 """Creates a MixNet Small model.
712807
@@ -1032,6 +1127,51 @@ def efficientnet_cc_b1_8e(pretrained=False, **kwargs):
10321127 return model
10331128
10341129
1130+ @register_model
1131+ def efficientnet_lite0 (pretrained = False , ** kwargs ):
1132+ """ EfficientNet-Lite0 """
1133+ # NOTE for train, drop_rate should be 0.2, drop_path_rate should be 0.2
1134+ model = _gen_efficientnet_lite (
1135+ 'efficientnet_lite0' , channel_multiplier = 1.0 , depth_multiplier = 1.0 , pretrained = pretrained , ** kwargs )
1136+ return model
1137+
1138+
1139+ @register_model
1140+ def efficientnet_lite1 (pretrained = False , ** kwargs ):
1141+ """ EfficientNet-Lite1 """
1142+ # NOTE for train, drop_rate should be 0.2, drop_path_rate should be 0.2
1143+ model = _gen_efficientnet_lite (
1144+ 'efficientnet_lite1' , channel_multiplier = 1.0 , depth_multiplier = 1.1 , pretrained = pretrained , ** kwargs )
1145+ return model
1146+
1147+
1148+ @register_model
1149+ def efficientnet_lite2 (pretrained = False , ** kwargs ):
1150+ """ EfficientNet-Lite2 """
1151+ # NOTE for train, drop_rate should be 0.3, drop_path_rate should be 0.2
1152+ model = _gen_efficientnet_lite (
1153+ 'efficientnet_lite2' , channel_multiplier = 1.1 , depth_multiplier = 1.2 , pretrained = pretrained , ** kwargs )
1154+ return model
1155+
1156+
1157+ @register_model
1158+ def efficientnet_lite3 (pretrained = False , ** kwargs ):
1159+ """ EfficientNet-Lite3 """
1160+ # NOTE for train, drop_rate should be 0.3, drop_path_rate should be 0.2
1161+ model = _gen_efficientnet_lite (
1162+ 'efficientnet_lite3' , channel_multiplier = 1.2 , depth_multiplier = 1.4 , pretrained = pretrained , ** kwargs )
1163+ return model
1164+
1165+
1166+ @register_model
1167+ def efficientnet_lite4 (pretrained = False , ** kwargs ):
1168+ """ EfficientNet-Lite4 """
1169+ # NOTE for train, drop_rate should be 0.4, drop_path_rate should be 0.2
1170+ model = _gen_efficientnet_lite (
1171+ 'efficientnet_lite4' , channel_multiplier = 1.4 , depth_multiplier = 1.8 , pretrained = pretrained , ** kwargs )
1172+ return model
1173+
1174+
10351175@register_model
10361176def tf_efficientnet_b0 (pretrained = False , ** kwargs ):
10371177 """ EfficientNet-B0. Tensorflow compatible variant """
@@ -1386,6 +1526,61 @@ def tf_efficientnet_cc_b1_8e(pretrained=False, **kwargs):
13861526 return model
13871527
13881528
1529+ @register_model
1530+ def tf_efficientnet_lite0 (pretrained = False , ** kwargs ):
1531+ """ EfficientNet-Lite0 """
1532+ # NOTE for train, drop_rate should be 0.2, drop_path_rate should be 0.2
1533+ kwargs ['bn_eps' ] = BN_EPS_TF_DEFAULT
1534+ kwargs ['pad_type' ] = 'same'
1535+ model = _gen_efficientnet_lite (
1536+ 'tf_efficientnet_lite0' , channel_multiplier = 1.0 , depth_multiplier = 1.0 , pretrained = pretrained , ** kwargs )
1537+ return model
1538+
1539+
1540+ @register_model
1541+ def tf_efficientnet_lite1 (pretrained = False , ** kwargs ):
1542+ """ EfficientNet-Lite1 """
1543+ # NOTE for train, drop_rate should be 0.2, drop_path_rate should be 0.2
1544+ kwargs ['bn_eps' ] = BN_EPS_TF_DEFAULT
1545+ kwargs ['pad_type' ] = 'same'
1546+ model = _gen_efficientnet_lite (
1547+ 'tf_efficientnet_lite1' , channel_multiplier = 1.0 , depth_multiplier = 1.1 , pretrained = pretrained , ** kwargs )
1548+ return model
1549+
1550+
1551+ @register_model
1552+ def tf_efficientnet_lite2 (pretrained = False , ** kwargs ):
1553+ """ EfficientNet-Lite2 """
1554+ # NOTE for train, drop_rate should be 0.3, drop_path_rate should be 0.2
1555+ kwargs ['bn_eps' ] = BN_EPS_TF_DEFAULT
1556+ kwargs ['pad_type' ] = 'same'
1557+ model = _gen_efficientnet_lite (
1558+ 'tf_efficientnet_lite2' , channel_multiplier = 1.1 , depth_multiplier = 1.2 , pretrained = pretrained , ** kwargs )
1559+ return model
1560+
1561+
1562+ @register_model
1563+ def tf_efficientnet_lite3 (pretrained = False , ** kwargs ):
1564+ """ EfficientNet-Lite3 """
1565+ # NOTE for train, drop_rate should be 0.3, drop_path_rate should be 0.2
1566+ kwargs ['bn_eps' ] = BN_EPS_TF_DEFAULT
1567+ kwargs ['pad_type' ] = 'same'
1568+ model = _gen_efficientnet_lite (
1569+ 'tf_efficientnet_lite3' , channel_multiplier = 1.2 , depth_multiplier = 1.4 , pretrained = pretrained , ** kwargs )
1570+ return model
1571+
1572+
1573+ @register_model
1574+ def tf_efficientnet_lite4 (pretrained = False , ** kwargs ):
1575+ """ EfficientNet-Lite4 """
1576+ # NOTE for train, drop_rate should be 0.4, drop_path_rate should be 0.2
1577+ kwargs ['bn_eps' ] = BN_EPS_TF_DEFAULT
1578+ kwargs ['pad_type' ] = 'same'
1579+ model = _gen_efficientnet_lite (
1580+ 'tf_efficientnet_lite4' , channel_multiplier = 1.4 , depth_multiplier = 1.8 , pretrained = pretrained , ** kwargs )
1581+ return model
1582+
1583+
13891584@register_model
13901585def mixnet_s (pretrained = False , ** kwargs ):
13911586 """Creates a MixNet Small model.
0 commit comments