@ -31,9 +31,9 @@ _models = [
' mnasnet_050 ' , ' mnasnet_075 ' , ' mnasnet_100 ' , ' mnasnet_b1 ' , ' mnasnet_140 ' , ' semnasnet_050 ' , ' semnasnet_075 ' ,
' mnasnet_050 ' , ' mnasnet_075 ' , ' mnasnet_100 ' , ' mnasnet_b1 ' , ' mnasnet_140 ' , ' semnasnet_050 ' , ' semnasnet_075 ' ,
' semnasnet_100 ' , ' mnasnet_a1 ' , ' semnasnet_140 ' , ' mnasnet_small ' , ' mobilenetv1_100 ' , ' mobilenetv2_100 ' ,
' semnasnet_100 ' , ' mnasnet_a1 ' , ' semnasnet_140 ' , ' mnasnet_small ' , ' mobilenetv1_100 ' , ' mobilenetv2_100 ' ,
' mobilenetv3_050 ' , ' mobilenetv3_075 ' , ' mobilenetv3_100 ' , ' chamnetv1_100 ' , ' chamnetv2_100 ' ,
' mobilenetv3_050 ' , ' mobilenetv3_075 ' , ' mobilenetv3_100 ' , ' chamnetv1_100 ' , ' chamnetv2_100 ' ,
' fbnetc_100 ' , ' spnasnet_100 ' , ' tflite_mnasnet_100 ' , ' tflite_semnasnet_100 ' , ' efficientnet_b0 ' ,
' fbnetc_100 ' , ' spnasnet_100 ' , ' tflite_mnasnet_100 ' , ' tflite_semnasnet_100 ' , ' efficientnet_b0 ' , ' efficientnet_b1 ' ,
' efficientnet_b 1' , ' efficientnet_b 2' , ' efficientnet_b3 ' , ' efficientnet_b4 ' , ' tf_efficientnet_b0 ' ,
' efficientnet_b 2' , ' efficientnet_b3 ' , ' efficientnet_b4 ' , ' efficientnet_b5 ' , ' tf_efficientnet_b0 ' ,
' tf_efficientnet_b1 ' , ' tf_efficientnet_b2 ' , ' tf_efficientnet_b3 ' ]
' tf_efficientnet_b1 ' , ' tf_efficientnet_b2 ' , ' tf_efficientnet_b3 ' , ' tf_efficientnet_b4 ' , ' tf_efficientnet_b5 ' ]
__all__ = [ ' GenEfficientNet ' , ' gen_efficientnet_model_names ' ] + _models
__all__ = [ ' GenEfficientNet ' , ' gen_efficientnet_model_names ' ] + _models
@ -91,6 +91,8 @@ default_cfgs = {
url = ' ' , input_size = ( 3 , 300 , 300 ) , pool_size = ( 10 , 10 ) ) ,
url = ' ' , input_size = ( 3 , 300 , 300 ) , pool_size = ( 10 , 10 ) ) ,
' efficientnet_b4 ' : _cfg (
' efficientnet_b4 ' : _cfg (
url = ' ' , input_size = ( 3 , 380 , 380 ) , pool_size = ( 12 , 12 ) ) ,
url = ' ' , input_size = ( 3 , 380 , 380 ) , pool_size = ( 12 , 12 ) ) ,
' efficientnet_b5 ' : _cfg (
url = ' ' , input_size = ( 3 , 456 , 456 ) , pool_size = ( 15 , 15 ) ) ,
' tf_efficientnet_b0 ' : _cfg (
' tf_efficientnet_b0 ' : _cfg (
url = ' https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b0-0af12548.pth ' ,
url = ' https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b0-0af12548.pth ' ,
input_size = ( 3 , 224 , 224 ) , interpolation = ' bicubic ' ) ,
input_size = ( 3 , 224 , 224 ) , interpolation = ' bicubic ' ) ,
@ -103,8 +105,15 @@ default_cfgs = {
' tf_efficientnet_b3 ' : _cfg (
' tf_efficientnet_b3 ' : _cfg (
url = ' https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b3-e3bd6955.pth ' ,
url = ' https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b3-e3bd6955.pth ' ,
input_size = ( 3 , 300 , 300 ) , pool_size = ( 10 , 10 ) , interpolation = ' bicubic ' , crop_pct = 0.904 ) ,
input_size = ( 3 , 300 , 300 ) , pool_size = ( 10 , 10 ) , interpolation = ' bicubic ' , crop_pct = 0.904 ) ,
' tf_efficientnet_b4 ' : _cfg (
url = ' https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b4-74ee3bed.pth ' ,
input_size = ( 3 , 380 , 380 ) , pool_size = ( 12 , 12 ) , interpolation = ' bicubic ' , crop_pct = 0.922 ) ,
' tf_efficientnet_b5 ' : _cfg (
url = ' https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_b5-c6949ce9.pth ' ,
input_size = ( 3 , 456 , 456 ) , pool_size = ( 15 , 15 ) , interpolation = ' bicubic ' , crop_pct = 0.934 )
}
}
_DEBUG = False
_DEBUG = False
# Default args for PyTorch BN impl
# Default args for PyTorch BN impl
@ -1436,6 +1445,19 @@ def efficientnet_b4(num_classes, in_chans=3, pretrained=False, **kwargs):
return model
return model
def efficientnet_b5 ( num_classes , in_chans = 3 , pretrained = False , * * kwargs ) :
""" EfficientNet-B5 """
# NOTE for train, drop_rate should be 0.4
default_cfg = default_cfgs [ ' efficientnet_b5 ' ]
model = _gen_efficientnet (
channel_multiplier = 1.6 , depth_multiplier = 2.2 ,
num_classes = num_classes , in_chans = in_chans , * * kwargs )
model . default_cfg = default_cfg
if pretrained :
load_pretrained ( model , default_cfg , num_classes , in_chans )
return model
def tf_efficientnet_b0 ( num_classes , in_chans = 3 , pretrained = False , * * kwargs ) :
def tf_efficientnet_b0 ( num_classes , in_chans = 3 , pretrained = False , * * kwargs ) :
""" EfficientNet-B0. Tensorflow compatible variant """
""" EfficientNet-B0. Tensorflow compatible variant """
default_cfg = default_cfgs [ ' tf_efficientnet_b0 ' ]
default_cfg = default_cfgs [ ' tf_efficientnet_b0 ' ]
@ -1492,5 +1514,33 @@ def tf_efficientnet_b3(num_classes, in_chans=3, pretrained=False, **kwargs):
return model
return model
def tf_efficientnet_b4 ( num_classes , in_chans = 3 , pretrained = False , * * kwargs ) :
""" EfficientNet-B4. Tensorflow compatible variant """
default_cfg = default_cfgs [ ' tf_efficientnet_b4 ' ]
kwargs [ ' bn_eps ' ] = _BN_EPS_TF_DEFAULT
kwargs [ ' padding_same ' ] = True
model = _gen_efficientnet (
channel_multiplier = 1.4 , depth_multiplier = 1.8 ,
num_classes = num_classes , in_chans = in_chans , * * kwargs )
model . default_cfg = default_cfg
if pretrained :
load_pretrained ( model , default_cfg , num_classes , in_chans )
return model
def tf_efficientnet_b5 ( num_classes , in_chans = 3 , pretrained = False , * * kwargs ) :
""" EfficientNet-B5. Tensorflow compatible variant """
default_cfg = default_cfgs [ ' tf_efficientnet_b5 ' ]
kwargs [ ' bn_eps ' ] = _BN_EPS_TF_DEFAULT
kwargs [ ' padding_same ' ] = True
model = _gen_efficientnet (
channel_multiplier = 1.6 , depth_multiplier = 2.2 ,
num_classes = num_classes , in_chans = in_chans , * * kwargs )
model . default_cfg = default_cfg
if pretrained :
load_pretrained ( model , default_cfg , num_classes , in_chans )
return model
def gen_efficientnet_model_names ( ) :
def gen_efficientnet_model_names ( ) :
return set ( _models )
return set ( _models )