EfficientNet-PyTorch icon indicating copy to clipboard operation
EfficientNet-PyTorch copied to clipboard

[Bug] Error loading when pretrained=False

Open zxytim opened this issue 5 years ago • 1 comments

When loading model with pretrained=False set, it will route to https://github.com/lukemelas/EfficientNet-PyTorch/blob/master/hubconf.py#L34 :

            model = _EfficientNet.from_name(
                model_name=model_name_,
                override_params={'num_classes': num_classes},
            )

which passes override_params to from_name method.

However, in https://github.com/lukemelas/EfficientNet-PyTorch/blob/master/efficientnet_pytorch/model.py#L321 , the from_name method declares override_params as keyword arguments.

def from_name(cls, model_name, in_channels=3, **override_params):

which will end up with an override_params variable containing a 'override_params' key. This causes exception being raised at https://github.com/lukemelas/EfficientNet-PyTorch/blob/master/efficientnet_pytorch/utils.py#L545

zxytim avatar Sep 26 '20 02:09 zxytim

You could do the following to solve that issue:

model = EfficientNet.from_name(in_channels=3, model_name='efficientnet-b7', **{'num_classes': 2}).to(device)

sainatarajan avatar Nov 20 '20 18:11 sainatarajan