-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Describe the bug
The bug happens when trying to specify local path to pretrained weights (in order to run model on devices with no access to the Internet). When passing a custom config as an argument to a function code falls when initializing an EfficientNet instance with the keyword argument 'cfg', which is not present in EfficientNet class init.
To Reproduce
from timm.models.efficientnet import _cfg, tf_efficientnet_b7_ns
config = _cfg(url='', file='../tf_efficientnet_b7_ns-1dbc32de.pth',
input_size=(3, 600, 600), pool_size=(19, 19), crop_pct=0.949)
model = tf_efficientnet_b7_ns(pretrained=True, model_cfg=config, drop_path_rate=0.2)
TypeError Traceback (most recent call last)
/tmp/ipykernel_4061624/3684105051.py in
3 config = _cfg(url='', file='../tf_efficientnet_b7_ns-1dbc32de.pth',
4 input_size=(3, 600, 600), pool_size=(19, 19), crop_pct=0.949)
----> 5 model = tf_efficientnet_b7_ns(pretrained=True, model_cfg=config, drop_path_rate=0.2)~/.imgenv-fakedetection-voronov-0/lib/python3.7/site-packages/timm/models/efficientnet.py in tf_efficientnet_b7_ns(pretrained, **kwargs)
1916 kwargs['pad_type'] = 'same'
1917 model = _gen_efficientnet(
-> 1918 'tf_efficientnet_b7_ns', channel_multiplier=2.0, depth_multiplier=3.1, pretrained=pretrained, **kwargs)
1919 return model
1920~/.imgenv-fakedetection-voronov-0/lib/python3.7/site-packages/timm/models/efficientnet.py in _gen_efficientnet(variant, channel_multiplier, depth_multiplier, pretrained, **kwargs)
842 **kwargs,
843 )
--> 844 model = _create_effnet(variant, pretrained, **model_kwargs)
845 return model
846~/.imgenv-fakedetection-voronov-0/lib/python3.7/site-packages/timm/models/efficientnet.py in _create_effnet(variant, pretrained, **kwargs)
597 pretrained_strict=not features_only,
598 kwargs_filter=kwargs_filter,
--> 599 **kwargs)
600 if features_only:
601 model.default_cfg = default_cfg_for_features(model.default_cfg)~/.imgenv-fakedetection-voronov-0/lib/python3.7/site-packages/timm/models/helpers.py in build_model_with_cfg(model_cls, variant, pretrained, default_cfg, model_cfg, feature_cfg, pretrained_strict, pretrained_filter_fn, pretrained_custom_load, kwargs_filter, **kwargs)
451
452 # Build the model
--> 453 model = model_cls(**kwargs) if model_cfg is None else model_cls(cfg=model_cfg, **kwargs)
454 model.default_cfg = default_cfg
455TypeError: init() got an unexpected keyword argument 'cfg'
Expected behavior
I expect the model to be created with weights loaded from local file.
Desktop (please complete the following information):
- OS: Ubuntu 18.04
- timm==0.5.4
- PyTorch version: 1.9.0+cu111