|
|
|
@ -521,20 +521,23 @@ class ResNet(nn.Module):
|
|
|
|
|
|
|
|
|
|
def _create_resnet_with_cfg(variant, default_cfg, pretrained=False, **kwargs):
|
|
|
|
|
assert isinstance(default_cfg, dict)
|
|
|
|
|
load_strict, features = True, False
|
|
|
|
|
features = False
|
|
|
|
|
out_indices = None
|
|
|
|
|
if kwargs.pop('features_only', False):
|
|
|
|
|
load_strict, features = False, True
|
|
|
|
|
features = True
|
|
|
|
|
kwargs.pop('num_classes', 0)
|
|
|
|
|
out_indices = kwargs.pop('out_indices', (0, 1, 2, 3, 4))
|
|
|
|
|
pruned = kwargs.pop('pruned', False)
|
|
|
|
|
|
|
|
|
|
model = ResNet(**kwargs)
|
|
|
|
|
model.default_cfg = copy.deepcopy(default_cfg)
|
|
|
|
|
if kwargs.pop('pruned', False):
|
|
|
|
|
|
|
|
|
|
if pruned:
|
|
|
|
|
model = adapt_model_from_file(model, variant)
|
|
|
|
|
if pretrained:
|
|
|
|
|
load_pretrained(
|
|
|
|
|
model,
|
|
|
|
|
num_classes=kwargs.get('num_classes', 0), in_chans=kwargs.get('in_chans', 3), strict=load_strict)
|
|
|
|
|
num_classes=kwargs.get('num_classes', 0), in_chans=kwargs.get('in_chans', 3), strict=not features)
|
|
|
|
|
if features:
|
|
|
|
|
model = FeatureNet(model, out_indices=out_indices)
|
|
|
|
|
return model
|
|
|
|
|