Unverified Commit f3b174be authored by Pavel Yakubovskiy's avatar Pavel Yakubovskiy Committed by GitHub

Add efficientnets (#116)(#118)

* Add efficientnet backbones (B0-B3)
* Remove `input_tensor` kwarg
* Update README
parent d513142b
......@@ -155,19 +155,20 @@ PSPNet FPN
.. table::
=========== =====
Type Names
=========== =====
VGG ``'vgg16' 'vgg19'``
ResNet ``'resnet18' 'resnet34' 'resnet50' 'resnet101' 'resnet152'``
SE-ResNet ``'seresnet18' 'seresnet34' 'seresnet50' 'seresnet101' 'seresnet152'``
ResNeXt ``'resnext50' 'resnext101'``
SE-ResNeXt ``'seresnext50' 'seresnext101'``
SENet154 ``'senet154'``
DenseNet ``'densenet121' 'densenet169' 'densenet201'``
Inception ``'inceptionv3' 'inceptionresnetv2'``
MobileNet ``'mobilenet' 'mobilenetv2'``
=========== =====
============= =====
Type Names
============= =====
VGG ``'vgg16' 'vgg19'``
ResNet ``'resnet18' 'resnet34' 'resnet50' 'resnet101' 'resnet152'``
SE-ResNet ``'seresnet18' 'seresnet34' 'seresnet50' 'seresnet101' 'seresnet152'``
ResNeXt ``'resnext50' 'resnext101'``
SE-ResNeXt ``'seresnext50' 'seresnext101'``
SENet154 ``'senet154'``
DenseNet ``'densenet121' 'densenet169' 'densenet201'``
Inception ``'inceptionv3' 'inceptionresnetv2'``
MobileNet ``'mobilenet' 'mobilenetv2'``
EfficientNet ``'efficientnetb0' 'efficientnetb1' 'efficientnetb2' 'efficientnetb3'``
============= =====
.. epigraph::
All backbones have weights trained on 2012 ILSVRC ImageNet dataset (``encoder_weights='imagenet'``).
......
import efficientnet as eff
from classification_models import Classifiers
from classification_models import resnext
......@@ -14,6 +15,18 @@ Classifiers._models.update({
'resnext101': [resnext.ResNeXt101, resnext.models.preprocess_input],
'mobilenet': [mbn.MobileNet, mbn.preprocess_input],
'mobilenetv2': [mbn2.MobileNetV2, mbn2.preprocess_input],
'efficientnetb0': [eff.EfficientNetB0, eff.preprocess_input],
'efficientnetb1': [eff.EfficientNetB1, eff.preprocess_input],
'efficientnetb2': [eff.EfficientNetB2, eff.preprocess_input],
'efficientnetb3': [eff.EfficientNetB3, eff.preprocess_input],
# weights are not released
# 'efficientnetb4': [eff.EfficientNetB4, eff.preprocess_input],
# 'efficientnetb5': [eff.EfficientNetB5, eff.preprocess_input],
# 'efficientnetb6': [eff.EfficientNetB6, eff.preprocess_input],
# 'efficientnetb7': [eff.EfficientNetB7, eff.preprocess_input],
})
DEFAULT_FEATURE_LAYERS = {
......@@ -59,7 +72,19 @@ DEFAULT_FEATURE_LAYERS = {
# Mobile Nets
'mobilenet': ('conv_pw_11_relu', 'conv_pw_5_relu', 'conv_pw_3_relu', 'conv_pw_1_relu'),
'mobilenetv2': ('block_13_expand_relu', 'block_6_expand_relu', 'block_3_expand_relu', 'block_1_expand_relu'),
# EfficientNets
'efficientnetb0': (169, 77, 47, 17),
'efficientnetb1': (246, 122, 76, 30),
'efficientnetb2': (246, 122, 76, 30),
'efficientnetb3': (278, 122, 76, 30),
# weights are not released
# 'efficientnetb4': (342, 154, 92, 30),
# 'efficientnetb5': (419, 199, 121, 43),
# 'efficientnetb6': (483, 231, 137, 43),
# 'efficientnetb7': (592, 276, 166, 56),
}
......
......@@ -11,13 +11,13 @@ old_args_map = {
'interpolation': 'final_interpolation',
'upsample_rates': None, # removed
'last_upsample': None, # removed
'input_tensor': None, # removed
}
@legacy_support(old_args_map)
def FPN(backbone_name='vgg16',
input_shape=(None, None, 3),
input_tensor=None,
classes=21,
activation='softmax',
encoder_weights='imagenet',
......@@ -61,7 +61,6 @@ def FPN(backbone_name='vgg16',
backbone = get_backbone(backbone_name,
input_shape=input_shape,
input_tensor=input_tensor,
weights=encoder_weights,
include_top=False)
......
......@@ -62,7 +62,6 @@ def Linknet(backbone_name='vgg16',
backbone = get_backbone(backbone_name,
input_shape=input_shape,
input_tensor=None,
weights=encoder_weights,
include_top=False)
......
......@@ -84,7 +84,6 @@ def PSPNet(backbone_name='vgg16',
backbone = get_backbone(backbone_name,
input_shape=input_shape,
input_tensor=None,
weights=encoder_weights,
include_top=False)
......
......@@ -58,7 +58,6 @@ def Unet(backbone_name='vgg16',
backbone = get_backbone(backbone_name,
input_shape=input_shape,
input_tensor=None,
weights=encoder_weights,
include_top=False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment