|
|
|
@ -5,10 +5,9 @@ by Ross Wightman
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
|
|
|
|
|
from .helpers import load_pretrained
|
|
|
|
|
from .layers import SEModule
|
|
|
|
|
from .registry import register_model
|
|
|
|
|
from .resnet import ResNet, Bottleneck, BasicBlock
|
|
|
|
|
from .resnet import _create_resnet_with_cfg, Bottleneck, BasicBlock
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _cfg(url='', **kwargs):
|
|
|
|
@ -34,9 +33,6 @@ default_cfgs = {
|
|
|
|
|
'gluon_resnet50_v1d': _cfg(url='https://github.com/rwightman/pytorch-pretrained-gluonresnet/releases/download/v0.1/gluon_resnet50_v1d-818a1b1b.pth'),
|
|
|
|
|
'gluon_resnet101_v1d': _cfg(url='https://github.com/rwightman/pytorch-pretrained-gluonresnet/releases/download/v0.1/gluon_resnet101_v1d-0f9c8644.pth'),
|
|
|
|
|
'gluon_resnet152_v1d': _cfg(url='https://github.com/rwightman/pytorch-pretrained-gluonresnet/releases/download/v0.1/gluon_resnet152_v1d-bd354e12.pth'),
|
|
|
|
|
'gluon_resnet50_v1e': _cfg(url=''),
|
|
|
|
|
'gluon_resnet101_v1e': _cfg(url=''),
|
|
|
|
|
'gluon_resnet152_v1e': _cfg(url=''),
|
|
|
|
|
'gluon_resnet50_v1s': _cfg(url='https://github.com/rwightman/pytorch-pretrained-gluonresnet/releases/download/v0.1/gluon_resnet50_v1s-1762acc0.pth'),
|
|
|
|
|
'gluon_resnet101_v1s': _cfg(url='https://github.com/rwightman/pytorch-pretrained-gluonresnet/releases/download/v0.1/gluon_resnet101_v1s-60fe0cc1.pth'),
|
|
|
|
|
'gluon_resnet152_v1s': _cfg(url='https://github.com/rwightman/pytorch-pretrained-gluonresnet/releases/download/v0.1/gluon_resnet152_v1s-dcc41b81.pth'),
|
|
|
|
@ -50,318 +46,190 @@ default_cfgs = {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _create_resnet(variant, pretrained=False, **kwargs):
|
|
|
|
|
default_cfg = default_cfgs[variant]
|
|
|
|
|
return _create_resnet_with_cfg(variant, default_cfg, pretrained=pretrained, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet18_v1b(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet18_v1b(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-18 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet18_v1b']
|
|
|
|
|
model = ResNet(BasicBlock, [2, 2, 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
|
|
|
|
|
model_args = dict(block=BasicBlock, layers=[2, 2, 2, 2], **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet18_v1b', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet34_v1b(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet34_v1b(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-34 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet34_v1b']
|
|
|
|
|
model = ResNet(BasicBlock, [3, 4, 6, 3], 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
|
|
|
|
|
model_args = dict(block=BasicBlock, layers=[3, 4, 6, 3], **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet34_v1b', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet50_v1b(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet50_v1b(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-50 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet50_v1b']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 4, 6, 3], 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
|
|
|
|
|
model_args = dict(block=Bottleneck, layers=[3, 4, 6, 3], **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet50_v1b', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet101_v1b(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet101_v1b(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-101 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet101_v1b']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 4, 23, 3], 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
|
|
|
|
|
model_args = dict(block=Bottleneck, layers=[3, 4, 23, 3], **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet101_v1b', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet152_v1b(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet152_v1b(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-152 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet152_v1b']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 8, 36, 3], 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
|
|
|
|
|
model_args = dict(block=Bottleneck, layers=[3, 8, 36, 3], **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet152_v1b', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet50_v1c(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet50_v1c(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-50 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet50_v1c']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 4, 6, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=32, stem_type='deep', **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(block=Bottleneck, layers=[3, 4, 6, 3], stem_width=32, stem_type='deep', **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet50_v1c', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet101_v1c(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet101_v1c(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-101 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet101_v1c']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 4, 23, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=32, stem_type='deep', **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(block=Bottleneck, layers=[3, 4, 23, 3], stem_width=32, stem_type='deep', **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet101_v1c', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet152_v1c(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet152_v1c(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-152 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet152_v1c']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 8, 36, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=32, stem_type='deep', **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(block=Bottleneck, layers=[3, 8, 36, 3], stem_width=32, stem_type='deep', **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet152_v1c', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet50_v1d(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet50_v1d(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-50 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet50_v1d']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 4, 6, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=32, stem_type='deep', avg_down=True, **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(
|
|
|
|
|
block=Bottleneck, layers=[3, 4, 6, 3], stem_width=32, stem_type='deep', avg_down=True, **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet50_v1d', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet101_v1d(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet101_v1d(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-101 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet101_v1d']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 4, 23, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=32, stem_type='deep', avg_down=True, **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(
|
|
|
|
|
block=Bottleneck, layers=[3, 4, 23, 3], stem_width=32, stem_type='deep', avg_down=True, **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet101_v1d', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet152_v1d(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet152_v1d(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-152 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet152_v1d']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 8, 36, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=32, stem_type='deep', avg_down=True, **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet50_v1e(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-50-V1e model. No pretrained weights for any 'e' variants
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet50_v1e']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 4, 6, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=64, stem_type='deep', avg_down=True, **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(
|
|
|
|
|
block=Bottleneck, layers=[3, 8, 36, 3], stem_width=32, stem_type='deep', avg_down=True, **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet152_v1d', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet101_v1e(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-101 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet101_v1e']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 4, 23, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=64, stem_type='deep', avg_down=True, **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet152_v1e(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-152 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet152_v1e']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 8, 36, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=64, stem_type='deep', avg_down=True, **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet50_v1s(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet50_v1s(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-50 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet50_v1s']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 4, 6, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=64, stem_type='deep', **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(
|
|
|
|
|
block=Bottleneck, layers=[3, 4, 6, 3], stem_width=64, stem_type='deep', **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet50_v1s', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet101_v1s(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet101_v1s(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-101 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet101_v1s']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 4, 23, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=64, stem_type='deep', **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(
|
|
|
|
|
block=Bottleneck, layers=[3, 4, 23, 3], stem_width=64, stem_type='deep', **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet101_v1s', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnet152_v1s(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnet152_v1s(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNet-152 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnet152_v1s']
|
|
|
|
|
model = ResNet(Bottleneck, [3, 8, 36, 3], num_classes=num_classes, in_chans=in_chans,
|
|
|
|
|
stem_width=64, stem_type='deep', **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(
|
|
|
|
|
block=Bottleneck, layers=[3, 8, 36, 3], stem_width=64, stem_type='deep', **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnet152_v1s', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnext50_32x4d(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnext50_32x4d(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNeXt50-32x4d model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnext50_32x4d']
|
|
|
|
|
model = ResNet(
|
|
|
|
|
Bottleneck, [3, 4, 6, 3], cardinality=32, base_width=4,
|
|
|
|
|
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
|
|
|
|
|
model_args = dict(block=Bottleneck, layers=[3, 4, 6, 3], cardinality=32, base_width=4, **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnext50_32x4d', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnext101_32x4d(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnext101_32x4d(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNeXt-101 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnext101_32x4d']
|
|
|
|
|
model = ResNet(
|
|
|
|
|
Bottleneck, [3, 4, 23, 3], cardinality=32, base_width=4,
|
|
|
|
|
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
|
|
|
|
|
model_args = dict(block=Bottleneck, layers=[3, 4, 23, 3], cardinality=32, base_width=4, **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnext101_32x4d', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_resnext101_64x4d(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_resnext101_64x4d(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a ResNeXt-101 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_resnext101_64x4d']
|
|
|
|
|
model = ResNet(
|
|
|
|
|
Bottleneck, [3, 4, 23, 3], cardinality=64, base_width=4,
|
|
|
|
|
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
|
|
|
|
|
model_args = dict(block=Bottleneck, layers=[3, 4, 23, 3], cardinality=64, base_width=4, **kwargs)
|
|
|
|
|
return _create_resnet('gluon_resnext101_64x4d', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_seresnext50_32x4d(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_seresnext50_32x4d(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a SEResNeXt50-32x4d model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_seresnext50_32x4d']
|
|
|
|
|
model = ResNet(
|
|
|
|
|
Bottleneck, [3, 4, 6, 3], cardinality=32, base_width=4,
|
|
|
|
|
num_classes=num_classes, in_chans=in_chans, block_args=dict(attn_layer=SEModule), **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(
|
|
|
|
|
block=Bottleneck, layers=[3, 4, 6, 3], cardinality=32, base_width=4,
|
|
|
|
|
block_args=dict(attn_layer=SEModule), **kwargs)
|
|
|
|
|
return _create_resnet('gluon_seresnext50_32x4d', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_seresnext101_32x4d(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_seresnext101_32x4d(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a SEResNeXt-101-32x4d model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_seresnext101_32x4d']
|
|
|
|
|
model = ResNet(
|
|
|
|
|
Bottleneck, [3, 4, 23, 3], cardinality=32, base_width=4,
|
|
|
|
|
num_classes=num_classes, in_chans=in_chans, block_args=dict(attn_layer=SEModule), **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(
|
|
|
|
|
block=Bottleneck, layers=[3, 4, 23, 3], cardinality=32, base_width=4,
|
|
|
|
|
block_args=dict(attn_layer=SEModule), **kwargs)
|
|
|
|
|
return _create_resnet('gluon_seresnext101_32x4d', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_seresnext101_64x4d(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_seresnext101_64x4d(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs a SEResNeXt-101-64x4d model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_seresnext101_64x4d']
|
|
|
|
|
block_args = dict(attn_layer=SEModule)
|
|
|
|
|
model = ResNet(
|
|
|
|
|
Bottleneck, [3, 4, 23, 3], cardinality=64, base_width=4,
|
|
|
|
|
num_classes=num_classes, in_chans=in_chans, block_args=block_args, **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
model_args = dict(
|
|
|
|
|
block=Bottleneck, layers=[3, 4, 23, 3], cardinality=64, base_width=4,
|
|
|
|
|
block_args=dict(attn_layer=SEModule), **kwargs)
|
|
|
|
|
return _create_resnet('gluon_seresnext101_64x4d', pretrained, **model_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register_model
|
|
|
|
|
def gluon_senet154(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
|
|
|
|
|
def gluon_senet154(pretrained=False, **kwargs):
|
|
|
|
|
"""Constructs an SENet-154 model.
|
|
|
|
|
"""
|
|
|
|
|
default_cfg = default_cfgs['gluon_senet154']
|
|
|
|
|
block_args = dict(attn_layer=SEModule)
|
|
|
|
|
model = ResNet(
|
|
|
|
|
Bottleneck, [3, 8, 36, 3], cardinality=64, base_width=4, stem_type='deep', down_kernel_size=3,
|
|
|
|
|
block_reduce_first=2, num_classes=num_classes, in_chans=in_chans, block_args=block_args, **kwargs)
|
|
|
|
|
model.default_cfg = default_cfg
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(model, default_cfg, num_classes, in_chans)
|
|
|
|
|
return model
|
|
|
|
|
|
|
|
|
|
model_args = dict(
|
|
|
|
|
block=Bottleneck, layers=[3, 8, 36, 3], cardinality=64, base_width=4, stem_type='deep',
|
|
|
|
|
down_kernel_size=3, block_reduce_first=2, block_args=dict(attn_layer=SEModule), **kwargs)
|
|
|
|
|
return _create_resnet('gluon_senet154', pretrained, **model_args)
|
|
|
|
|