Skip to content

Mobile resnest #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion resnest/gluon/resnest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,37 @@
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"""ResNeSt implemented in Gluon."""

__all__ = ['resnest50', 'resnest101',
__all__ = ['resnest14', 'resnest26',
'resnest50', 'resnest101',
'resnest200', 'resnest269']

from .resnet import ResNet, Bottleneck
from mxnet import cpu

def resnest14(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs):
model = ResNet(Bottleneck, [1, 1, 1, 1],
radix=2, cardinality=1, bottleneck_width=64,
deep_stem=True, avg_down=True,
avd=True, avd_first=False,
use_splat=True, dropblock_prob=0.0,
name_prefix='resnest_', **kwargs)
if pretrained:
from .model_store import get_model_file
model.load_parameters(get_model_file('resnest14', root=root), ctx=ctx)
return model

def resnest26(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs):
model = ResNet(Bottleneck, [2, 2, 2, 2],
radix=2, cardinality=1, bottleneck_width=64,
deep_stem=True, avg_down=True,
avd=True, avd_first=False,
use_splat=True, dropblock_prob=0.1,
name_prefix='resnest_', **kwargs)
if pretrained:
from .model_store import get_model_file
model.load_parameters(get_model_file('resnest26', root=root), ctx=ctx)
return model

def resnest50(pretrained=False, root='~/.mxnet/models', ctx=cpu(0), **kwargs):
model = ResNet(Bottleneck, [3, 4, 6, 3],
radix=2, cardinality=1, bottleneck_width=64,
Expand Down
22 changes: 21 additions & 1 deletion resnest/torch/resnest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch
from .resnet import ResNet, Bottleneck

__all__ = ['resnest50', 'resnest101', 'resnest200', 'resnest269']
__all__ = ['resnest14', 'resnest26', 'resnest50', 'resnest101', 'resnest200', 'resnest269']

_url_format = 'https://hangzh.s3.amazonaws.com/encoding/models/{}-{}.pth'

Expand All @@ -30,6 +30,26 @@ def short_hash(name):
name in _model_sha256.keys()
}

def resnest14(pretrained=False, root='~/.encoding/models', **kwargs):
model = ResNet(Bottleneck, [1, 1, 1, 1],
radix=2, groups=1, bottleneck_width=64,
deep_stem=True, stem_width=32, avg_down=True,
avd=True, avd_first=False, **kwargs)
if pretrained:
model.load_state_dict(torch.hub.load_state_dict_from_url(
resnest_model_urls['resnest14'], progress=True, check_hash=True))
return model

def resnest26(pretrained=False, root='~/.encoding/models', **kwargs):
model = ResNet(Bottleneck, [2, 2, 2, 2],
radix=2, groups=1, bottleneck_width=64,
deep_stem=True, stem_width=32, avg_down=True,
avd=True, avd_first=False, **kwargs)
if pretrained:
model.load_state_dict(torch.hub.load_state_dict_from_url(
resnest_model_urls['resnest26'], progress=True, check_hash=True))
return model

def resnest50(pretrained=False, root='~/.encoding/models', **kwargs):
model = ResNet(Bottleneck, [3, 4, 6, 3],
radix=2, groups=1, bottleneck_width=64,
Expand Down