Ejemplo n.º 1
0
def resnet152(pretrained=True, root='~/.gluoncvth/models', **kwargs):
    """Constructs a ResNet-152 model.
    Args:
        pretrained (bool): If True, returns a model pre-trained on ImageNet
    """
    model = ResNet(Bottleneck, [3, 8, 36, 3], **kwargs)
    if pretrained:
        d = torch.load(get_model_file('resnet101', root=root))
        d = warp_dict_fn(d)
        try:
            model.load_state_dict(d, strict=True)
        except Exception as e:
            print(e)
            print(
                "try load with strict = True failed , load with strict = False"
            )
            model.load_state_dict(d, strict=False)
    return model
Ejemplo n.º 2
0
def resnet101(pretrained=True, root='~/.gluoncvth/models', **kwargs):
    """Constructs a ResNet-101 model.
    Args:
        pretrained (bool): If True, returns a model pre-trained on ImageNet
    """
    se_kwargs = kwargs.pop('se_kwargs')
    block = partial(Bottleneck, se_kwargs=se_kwargs)
    block.expansion = Bottleneck.expansion
    model = ResNet(Bottleneck, [3, 4, 23, 3], **kwargs)
    if pretrained:
        d = torch.load(get_model_file('resnet101', root=root))
        d = warp_dict_fn(d)
        try:
            model.load_state_dict(d, strict=True)
        except Exception as e:
            print(e)
            print(
                "try load with strict = True failed , load with strict = False"
            )
            model.load_state_dict(d, strict=False)
    return model