Update EfficientNet comments, MobileNetV3 non-TF create fns, fix factory arg checks, bump PyTorch version req to 1.2

pull/53/head
Ross Wightman 5 years ago
parent eccbadca74
commit 6ca0828166

@ -1,3 +1,3 @@
torch>=1.1.0 torch>=1.2.0
torchvision>=0.3.0 torchvision>=0.4.0
pyyaml pyyaml

@ -845,8 +845,7 @@ def spnasnet_100(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_b0(pretrained=False, **kwargs): def efficientnet_b0(pretrained=False, **kwargs):
""" EfficientNet-B0 """ """ EfficientNet-B0 """
# NOTE for train, drop_rate should be 0.2 # NOTE for train, drop_rate should be 0.2, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet( model = _gen_efficientnet(
'efficientnet_b0', channel_multiplier=1.0, depth_multiplier=1.0, pretrained=pretrained, **kwargs) 'efficientnet_b0', channel_multiplier=1.0, depth_multiplier=1.0, pretrained=pretrained, **kwargs)
return model return model
@ -855,8 +854,7 @@ def efficientnet_b0(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_b1(pretrained=False, **kwargs): def efficientnet_b1(pretrained=False, **kwargs):
""" EfficientNet-B1 """ """ EfficientNet-B1 """
# NOTE for train, drop_rate should be 0.2 # NOTE for train, drop_rate should be 0.2, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet( model = _gen_efficientnet(
'efficientnet_b1', channel_multiplier=1.0, depth_multiplier=1.1, pretrained=pretrained, **kwargs) 'efficientnet_b1', channel_multiplier=1.0, depth_multiplier=1.1, pretrained=pretrained, **kwargs)
return model return model
@ -865,8 +863,7 @@ def efficientnet_b1(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_b2(pretrained=False, **kwargs): def efficientnet_b2(pretrained=False, **kwargs):
""" EfficientNet-B2 """ """ EfficientNet-B2 """
# NOTE for train, drop_rate should be 0.3 # NOTE for train, drop_rate should be 0.3, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet( model = _gen_efficientnet(
'efficientnet_b2', channel_multiplier=1.1, depth_multiplier=1.2, pretrained=pretrained, **kwargs) 'efficientnet_b2', channel_multiplier=1.1, depth_multiplier=1.2, pretrained=pretrained, **kwargs)
return model return model
@ -875,8 +872,7 @@ def efficientnet_b2(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_b3(pretrained=False, **kwargs): def efficientnet_b3(pretrained=False, **kwargs):
""" EfficientNet-B3 """ """ EfficientNet-B3 """
# NOTE for train, drop_rate should be 0.3 # NOTE for train, drop_rate should be 0.3, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet( model = _gen_efficientnet(
'efficientnet_b3', channel_multiplier=1.2, depth_multiplier=1.4, pretrained=pretrained, **kwargs) 'efficientnet_b3', channel_multiplier=1.2, depth_multiplier=1.4, pretrained=pretrained, **kwargs)
return model return model
@ -885,8 +881,7 @@ def efficientnet_b3(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_b4(pretrained=False, **kwargs): def efficientnet_b4(pretrained=False, **kwargs):
""" EfficientNet-B4 """ """ EfficientNet-B4 """
# NOTE for train, drop_rate should be 0.4 # NOTE for train, drop_rate should be 0.4, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet( model = _gen_efficientnet(
'efficientnet_b4', channel_multiplier=1.4, depth_multiplier=1.8, pretrained=pretrained, **kwargs) 'efficientnet_b4', channel_multiplier=1.4, depth_multiplier=1.8, pretrained=pretrained, **kwargs)
return model return model
@ -895,8 +890,7 @@ def efficientnet_b4(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_b5(pretrained=False, **kwargs): def efficientnet_b5(pretrained=False, **kwargs):
""" EfficientNet-B5 """ """ EfficientNet-B5 """
# NOTE for train, drop_rate should be 0.4 # NOTE for train, drop_rate should be 0.4, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet( model = _gen_efficientnet(
'efficientnet_b5', channel_multiplier=1.6, depth_multiplier=2.2, pretrained=pretrained, **kwargs) 'efficientnet_b5', channel_multiplier=1.6, depth_multiplier=2.2, pretrained=pretrained, **kwargs)
return model return model
@ -905,8 +899,7 @@ def efficientnet_b5(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_b6(pretrained=False, **kwargs): def efficientnet_b6(pretrained=False, **kwargs):
""" EfficientNet-B6 """ """ EfficientNet-B6 """
# NOTE for train, drop_rate should be 0.5 # NOTE for train, drop_rate should be 0.5, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet( model = _gen_efficientnet(
'efficientnet_b6', channel_multiplier=1.8, depth_multiplier=2.6, pretrained=pretrained, **kwargs) 'efficientnet_b6', channel_multiplier=1.8, depth_multiplier=2.6, pretrained=pretrained, **kwargs)
return model return model
@ -915,8 +908,7 @@ def efficientnet_b6(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_b7(pretrained=False, **kwargs): def efficientnet_b7(pretrained=False, **kwargs):
""" EfficientNet-B7 """ """ EfficientNet-B7 """
# NOTE for train, drop_rate should be 0.5 # NOTE for train, drop_rate should be 0.5, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet( model = _gen_efficientnet(
'efficientnet_b7', channel_multiplier=2.0, depth_multiplier=3.1, pretrained=pretrained, **kwargs) 'efficientnet_b7', channel_multiplier=2.0, depth_multiplier=3.1, pretrained=pretrained, **kwargs)
return model return model
@ -949,8 +941,7 @@ def efficientnet_el(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_cc_b0_4e(pretrained=False, **kwargs): def efficientnet_cc_b0_4e(pretrained=False, **kwargs):
""" EfficientNet-CondConv-B0 w/ 8 Experts """ """ EfficientNet-CondConv-B0 w/ 8 Experts """
# NOTE for train, drop_rate should be 0.2 # NOTE for train, drop_rate should be 0.2, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet_condconv( model = _gen_efficientnet_condconv(
'efficientnet_cc_b0_4e', channel_multiplier=1.0, depth_multiplier=1.0, pretrained=pretrained, **kwargs) 'efficientnet_cc_b0_4e', channel_multiplier=1.0, depth_multiplier=1.0, pretrained=pretrained, **kwargs)
return model return model
@ -959,8 +950,7 @@ def efficientnet_cc_b0_4e(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_cc_b0_8e(pretrained=False, **kwargs): def efficientnet_cc_b0_8e(pretrained=False, **kwargs):
""" EfficientNet-CondConv-B0 w/ 8 Experts """ """ EfficientNet-CondConv-B0 w/ 8 Experts """
# NOTE for train, drop_rate should be 0.2 # NOTE for train, drop_rate should be 0.2, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet_condconv( model = _gen_efficientnet_condconv(
'efficientnet_cc_b0_8e', channel_multiplier=1.0, depth_multiplier=1.0, experts_multiplier=2, 'efficientnet_cc_b0_8e', channel_multiplier=1.0, depth_multiplier=1.0, experts_multiplier=2,
pretrained=pretrained, **kwargs) pretrained=pretrained, **kwargs)
@ -969,8 +959,7 @@ def efficientnet_cc_b0_8e(pretrained=False, **kwargs):
@register_model @register_model
def efficientnet_cc_b1_8e(pretrained=False, **kwargs): def efficientnet_cc_b1_8e(pretrained=False, **kwargs):
""" EfficientNet-CondConv-B1 w/ 8 Experts """ """ EfficientNet-CondConv-B1 w/ 8 Experts """
# NOTE for train, drop_rate should be 0.2 # NOTE for train, drop_rate should be 0.2, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
model = _gen_efficientnet_condconv( model = _gen_efficientnet_condconv(
'efficientnet_cc_b1_8e', channel_multiplier=1.0, depth_multiplier=1.1, experts_multiplier=2, 'efficientnet_cc_b1_8e', channel_multiplier=1.0, depth_multiplier=1.1, experts_multiplier=2,
pretrained=pretrained, **kwargs) pretrained=pretrained, **kwargs)
@ -1008,7 +997,7 @@ def tf_efficientnet_b2(pretrained=False, **kwargs):
@register_model @register_model
def tf_efficientnet_b3(pretrained=False, num_classes=1000, in_chans=3, **kwargs): def tf_efficientnet_b3(pretrained=False, **kwargs):
""" EfficientNet-B3. Tensorflow compatible variant """ """ EfficientNet-B3. Tensorflow compatible variant """
kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['bn_eps'] = BN_EPS_TF_DEFAULT
kwargs['pad_type'] = 'same' kwargs['pad_type'] = 'same'
@ -1090,7 +1079,7 @@ def tf_efficientnet_b2_ap(pretrained=False, **kwargs):
@register_model @register_model
def tf_efficientnet_b3_ap(pretrained=False, num_classes=1000, in_chans=3, **kwargs): def tf_efficientnet_b3_ap(pretrained=False, **kwargs):
""" EfficientNet-B3. Tensorflow compatible variant """ """ EfficientNet-B3. Tensorflow compatible variant """
kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['bn_eps'] = BN_EPS_TF_DEFAULT
kwargs['pad_type'] = 'same' kwargs['pad_type'] = 'same'
@ -1186,8 +1175,7 @@ def tf_efficientnet_el(pretrained=False, **kwargs):
@register_model @register_model
def tf_efficientnet_cc_b0_4e(pretrained=False, **kwargs): def tf_efficientnet_cc_b0_4e(pretrained=False, **kwargs):
""" EfficientNet-CondConv-B0 w/ 4 Experts. Tensorflow compatible variant """ """ EfficientNet-CondConv-B0 w/ 4 Experts. Tensorflow compatible variant """
# NOTE for train, drop_rate should be 0.2 # NOTE for train, drop_rate should be 0.2, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['bn_eps'] = BN_EPS_TF_DEFAULT
kwargs['pad_type'] = 'same' kwargs['pad_type'] = 'same'
model = _gen_efficientnet_condconv( model = _gen_efficientnet_condconv(
@ -1198,8 +1186,7 @@ def tf_efficientnet_cc_b0_4e(pretrained=False, **kwargs):
@register_model @register_model
def tf_efficientnet_cc_b0_8e(pretrained=False, **kwargs): def tf_efficientnet_cc_b0_8e(pretrained=False, **kwargs):
""" EfficientNet-CondConv-B0 w/ 8 Experts. Tensorflow compatible variant """ """ EfficientNet-CondConv-B0 w/ 8 Experts. Tensorflow compatible variant """
# NOTE for train, drop_rate should be 0.2 # NOTE for train, drop_rate should be 0.2, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['bn_eps'] = BN_EPS_TF_DEFAULT
kwargs['pad_type'] = 'same' kwargs['pad_type'] = 'same'
model = _gen_efficientnet_condconv( model = _gen_efficientnet_condconv(
@ -1210,8 +1197,7 @@ def tf_efficientnet_cc_b0_8e(pretrained=False, **kwargs):
@register_model @register_model
def tf_efficientnet_cc_b1_8e(pretrained=False, **kwargs): def tf_efficientnet_cc_b1_8e(pretrained=False, **kwargs):
""" EfficientNet-CondConv-B1 w/ 8 Experts. Tensorflow compatible variant """ """ EfficientNet-CondConv-B1 w/ 8 Experts. Tensorflow compatible variant """
# NOTE for train, drop_rate should be 0.2 # NOTE for train, drop_rate should be 0.2, drop_connect_rate should be 0.2
#kwargs['drop_connect_rate'] = 0.2 # set when training, TODO add as cmd arg
kwargs['bn_eps'] = BN_EPS_TF_DEFAULT kwargs['bn_eps'] = BN_EPS_TF_DEFAULT
kwargs['pad_type'] = 'same' kwargs['pad_type'] = 'same'
model = _gen_efficientnet_condconv( model = _gen_efficientnet_condconv(
@ -1262,7 +1248,6 @@ def mixnet_xxl(pretrained=False, **kwargs):
"""Creates a MixNet Double Extra Large model. """Creates a MixNet Double Extra Large model.
Not a paper spec, experimental def by RW w/ depth scaling. Not a paper spec, experimental def by RW w/ depth scaling.
""" """
# kwargs['drop_connect_rate'] = 0.2
model = _gen_mixnet_m( model = _gen_mixnet_m(
'mixnet_xxl', channel_multiplier=2.4, depth_multiplier=1.3, pretrained=pretrained, **kwargs) 'mixnet_xxl', channel_multiplier=2.4, depth_multiplier=1.3, pretrained=pretrained, **kwargs)
return model return model

@ -25,8 +25,8 @@ def create_model(
""" """
margs = dict(pretrained=pretrained, num_classes=num_classes, in_chans=in_chans) margs = dict(pretrained=pretrained, num_classes=num_classes, in_chans=in_chans)
# Only gen_efficientnet models have support for batchnorm params or drop_connect_rate passed as args # Only EfficientNet and MobileNetV3 models have support for batchnorm params or drop_connect_rate passed as args
is_efficientnet = is_model_in_modules(model_name, ['gen_efficientnet']) is_efficientnet = is_model_in_modules(model_name, ['efficientnet', 'mobilenetv3'])
if not is_efficientnet: if not is_efficientnet:
kwargs.pop('bn_tf', None) kwargs.pop('bn_tf', None)
kwargs.pop('bn_momentum', None) kwargs.pop('bn_momentum', None)

@ -35,6 +35,8 @@ def _cfg(url='', **kwargs):
default_cfgs = { default_cfgs = {
'mobilenetv3_large_075': _cfg(url=''), 'mobilenetv3_large_075': _cfg(url=''),
'mobilenetv3_large_100': _cfg(url=''), 'mobilenetv3_large_100': _cfg(url=''),
'mobilenetv3_small_075': _cfg(url=''),
'mobilenetv3_small_100': _cfg(url=''),
'mobilenetv3_rw': _cfg( 'mobilenetv3_rw': _cfg(
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mobilenetv3_100-35495452.pth', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mobilenetv3_100-35495452.pth',
interpolation='bicubic'), interpolation='bicubic'),
@ -374,6 +376,35 @@ def _gen_mobilenet_v3(variant, channel_multiplier=1.0, pretrained=False, **kwarg
return model return model
@register_model
def mobilenetv3_large_075(pretrained=False, **kwargs):
""" MobileNet V3 """
model = _gen_mobilenet_v3('mobilenetv3_large_075', 0.75, pretrained=pretrained, **kwargs)
return model
@register_model
def mobilenetv3_large_100(pretrained=False, **kwargs):
""" MobileNet V3 """
model = _gen_mobilenet_v3('mobilenetv3_large_100', 1.0, pretrained=pretrained, **kwargs)
return model
@register_model
def mobilenetv3_small_075(pretrained=False, **kwargs):
""" MobileNet V3 """
model = _gen_mobilenet_v3('mobilenetv3_small_075', 0.75, pretrained=pretrained, **kwargs)
return model
@register_model
def mobilenetv3_small_100(pretrained=False, **kwargs):
print(kwargs)
""" MobileNet V3 """
model = _gen_mobilenet_v3('mobilenetv3_small_100', 1.0, pretrained=pretrained, **kwargs)
return model
@register_model @register_model
def mobilenetv3_rw(pretrained=False, **kwargs): def mobilenetv3_rw(pretrained=False, **kwargs):
""" MobileNet V3 """ """ MobileNet V3 """
@ -384,7 +415,6 @@ def mobilenetv3_rw(pretrained=False, **kwargs):
return model return model
@register_model @register_model
def tf_mobilenetv3_large_075(pretrained=False, **kwargs): def tf_mobilenetv3_large_075(pretrained=False, **kwargs):
""" MobileNet V3 """ """ MobileNet V3 """

Loading…
Cancel
Save