Add ResNet weights. 80.5 (top-1) ResNet-50-D, 77.1 ResNet-34-D, 72.7 ResNet-18-D.

pull/244/head
Ross Wightman 4 years ago
parent e39bf6ef59
commit c40384f5bd

@ -2,6 +2,10 @@
## What's New ## What's New
### Sept 18, 2020
* New ResNet 'D' weights. 72.7 (top-1) ResNet-18-D, 77.1 ResNet-34-D, 80.5 ResNet-50-D
* Added a few untrained defs for other ResNet models (66D, 101D, 152D, 200/200D)
### Sept 3, 2020 ### Sept 3, 2020
* New weights * New weights
* Wide-ResNet50 - 81.5 top-1 (vs 78.5 torchvision) * Wide-ResNet50 - 81.5 top-1 (vs 78.5 torchvision)

@ -35,26 +35,37 @@ def _cfg(url='', **kwargs):
default_cfgs = { default_cfgs = {
# ResNet and Wide ResNet # ResNet and Wide ResNet
'resnet18': _cfg(url='https://download.pytorch.org/models/resnet18-5c106cde.pth'), 'resnet18': _cfg(url='https://download.pytorch.org/models/resnet18-5c106cde.pth'),
'resnet18d': _cfg(
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet18d_ra2-48a79e06.pth',
interpolation='bicubic', first_conv='conv1.0'),
'resnet34': _cfg( 'resnet34': _cfg(
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet34-43635321.pth'), url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet34-43635321.pth'),
'resnet34d': _cfg(
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet34d_ra2-f8dcfcaf.pth',
interpolation='bicubic', first_conv='conv1.0'),
'resnet26': _cfg( 'resnet26': _cfg(
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet26-9aa10e23.pth', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet26-9aa10e23.pth',
interpolation='bicubic'), interpolation='bicubic'),
'resnet26d': _cfg( 'resnet26d': _cfg(
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet26d-69e92c46.pth', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet26d-69e92c46.pth',
interpolation='bicubic', interpolation='bicubic', first_conv='conv1.0'),
first_conv='conv1.0'),
'resnet50': _cfg( 'resnet50': _cfg(
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet50_ram-a26f946b.pth', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet50_ram-a26f946b.pth',
interpolation='bicubic'), interpolation='bicubic'),
'resnet50d': _cfg( 'resnet50d': _cfg(
url='', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet50d_ra2-464e36ba.pth',
interpolation='bicubic', interpolation='bicubic', first_conv='conv1.0'),
first_conv='conv1.0'), 'resnet66d': _cfg(url='', interpolation='bicubic', first_conv='conv1.0'),
'resnet101': _cfg(url='https://download.pytorch.org/models/resnet101-5d3b4d8f.pth'), 'resnet101': _cfg(url='', interpolation='bicubic'),
'resnet152': _cfg(url='https://download.pytorch.org/models/resnet152-b121ed2d.pth'), 'resnet101d': _cfg(url='', interpolation='bicubic', first_conv='conv1.0'),
'resnet152': _cfg(url='', interpolation='bicubic'),
'resnet152d': _cfg(url='', interpolation='bicubic', first_conv='conv1.0'),
'resnet200': _cfg(url='', interpolation='bicubic'),
'resnet200d': _cfg(url='', interpolation='bicubic', first_conv='conv1.0'),
'tv_resnet34': _cfg(url='https://download.pytorch.org/models/resnet34-333f7ec4.pth'), 'tv_resnet34': _cfg(url='https://download.pytorch.org/models/resnet34-333f7ec4.pth'),
'tv_resnet50': _cfg(url='https://download.pytorch.org/models/resnet50-19c8e357.pth'), 'tv_resnet50': _cfg(url='https://download.pytorch.org/models/resnet50-19c8e357.pth'),
'tv_resnet101': _cfg(url='https://download.pytorch.org/models/resnet101-5d3b4d8f.pth'),
'tv_resnet152': _cfg(url='https://download.pytorch.org/models/resnet152-b121ed2d.pth'),
'wide_resnet50_2': _cfg( 'wide_resnet50_2': _cfg(
url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/wide_resnet50_racm-8234f177.pth', url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/wide_resnet50_racm-8234f177.pth',
interpolation='bicubic'), interpolation='bicubic'),
@ -613,6 +624,15 @@ def resnet18(pretrained=False, **kwargs):
return _create_resnet('resnet18', pretrained, **model_args) return _create_resnet('resnet18', pretrained, **model_args)
@register_model
def resnet18d(pretrained=False, **kwargs):
"""Constructs a ResNet-18-D model.
"""
model_args = dict(
block=BasicBlock, layers=[2, 2, 2, 2], stem_width=32, stem_type='deep', avg_down=True, **kwargs)
return _create_resnet('resnet18d', pretrained, **model_args)
@register_model @register_model
def resnet34(pretrained=False, **kwargs): def resnet34(pretrained=False, **kwargs):
"""Constructs a ResNet-34 model. """Constructs a ResNet-34 model.
@ -621,6 +641,15 @@ def resnet34(pretrained=False, **kwargs):
return _create_resnet('resnet34', pretrained, **model_args) return _create_resnet('resnet34', pretrained, **model_args)
@register_model
def resnet34d(pretrained=False, **kwargs):
"""Constructs a ResNet-34-D model.
"""
model_args = dict(
block=BasicBlock, layers=[3, 4, 6, 3], stem_width=32, stem_type='deep', avg_down=True, **kwargs)
return _create_resnet('resnet34d', pretrained, **model_args)
@register_model @register_model
def resnet26(pretrained=False, **kwargs): def resnet26(pretrained=False, **kwargs):
"""Constructs a ResNet-26 model. """Constructs a ResNet-26 model.
@ -631,8 +660,7 @@ def resnet26(pretrained=False, **kwargs):
@register_model @register_model
def resnet26d(pretrained=False, **kwargs): def resnet26d(pretrained=False, **kwargs):
"""Constructs a ResNet-26 v1d model. """Constructs a ResNet-26-D model.
This is technically a 28 layer ResNet, sticking with 'd' modifier from Gluon for now.
""" """
model_args = dict(block=Bottleneck, layers=[2, 2, 2, 2], stem_width=32, stem_type='deep', avg_down=True, **kwargs) model_args = dict(block=Bottleneck, layers=[2, 2, 2, 2], stem_width=32, stem_type='deep', avg_down=True, **kwargs)
return _create_resnet('resnet26d', pretrained, **model_args) return _create_resnet('resnet26d', pretrained, **model_args)
@ -655,6 +683,14 @@ def resnet50d(pretrained=False, **kwargs):
return _create_resnet('resnet50d', pretrained, **model_args) return _create_resnet('resnet50d', pretrained, **model_args)
@register_model
def resnet66d(pretrained=False, **kwargs):
"""Constructs a ResNet-66-D model.
"""
model_args = dict(block=BasicBlock, layers=[3, 4, 23, 3], stem_width=32, stem_type='deep', avg_down=True, **kwargs)
return _create_resnet('resnet66d', pretrained, **model_args)
@register_model @register_model
def resnet101(pretrained=False, **kwargs): def resnet101(pretrained=False, **kwargs):
"""Constructs a ResNet-101 model. """Constructs a ResNet-101 model.
@ -663,6 +699,14 @@ def resnet101(pretrained=False, **kwargs):
return _create_resnet('resnet101', pretrained, **model_args) return _create_resnet('resnet101', pretrained, **model_args)
@register_model
def resnet101d(pretrained=False, **kwargs):
"""Constructs a ResNet-101-D model.
"""
model_args = dict(block=Bottleneck, layers=[3, 4, 23, 3], stem_width=32, stem_type='deep', avg_down=True, **kwargs)
return _create_resnet('resnet101d', pretrained, **model_args)
@register_model @register_model
def resnet152(pretrained=False, **kwargs): def resnet152(pretrained=False, **kwargs):
"""Constructs a ResNet-152 model. """Constructs a ResNet-152 model.
@ -671,6 +715,32 @@ def resnet152(pretrained=False, **kwargs):
return _create_resnet('resnet152', pretrained, **model_args) return _create_resnet('resnet152', pretrained, **model_args)
@register_model
def resnet152d(pretrained=False, **kwargs):
"""Constructs a ResNet-152-D model.
"""
model_args = dict(
block=Bottleneck, layers=[3, 8, 36, 3], stem_width=32, stem_type='deep', avg_down=True, **kwargs)
return _create_resnet('resnet152d', pretrained, **model_args)
@register_model
def resnet200(pretrained=False, **kwargs):
"""Constructs a ResNet-200 model.
"""
model_args = dict(block=Bottleneck, layers=[3, 24, 36, 3], **kwargs)
return _create_resnet('resnet200', pretrained, **model_args)
@register_model
def resnet200d(pretrained=False, **kwargs):
"""Constructs a ResNet-200-D model.
"""
model_args = dict(
block=Bottleneck, layers=[3, 24, 36, 3], stem_width=32, stem_type='deep', avg_down=True, **kwargs)
return _create_resnet('resnet200d', pretrained, **model_args)
@register_model @register_model
def tv_resnet34(pretrained=False, **kwargs): def tv_resnet34(pretrained=False, **kwargs):
"""Constructs a ResNet-34 model with original Torchvision weights. """Constructs a ResNet-34 model with original Torchvision weights.
@ -687,6 +757,22 @@ def tv_resnet50(pretrained=False, **kwargs):
return _create_resnet('tv_resnet50', pretrained, **model_args) return _create_resnet('tv_resnet50', pretrained, **model_args)
@register_model
def tv_resnet101(pretrained=False, **kwargs):
"""Constructs a ResNet-101 model w/ Torchvision pretrained weights.
"""
model_args = dict(block=Bottleneck, layers=[3, 4, 23, 3], **kwargs)
return _create_resnet('tv_resnet101', pretrained, **model_args)
@register_model
def tv_resnet152(pretrained=False, **kwargs):
"""Constructs a ResNet-152 model w/ Torchvision pretrained weights.
"""
model_args = dict(block=Bottleneck, layers=[3, 8, 36, 3], **kwargs)
return _create_resnet('tv_resnet152', pretrained, **model_args)
@register_model @register_model
def wide_resnet50_2(pretrained=False, **kwargs): def wide_resnet50_2(pretrained=False, **kwargs):
"""Constructs a Wide ResNet-50-2 model. """Constructs a Wide ResNet-50-2 model.

Loading…
Cancel
Save