facebookresearch / ConvNeXt

Code release for ConvNeXt model
MIT License
5.78k stars 696 forks source link

__init__() got an unexpected keyword argument 'pretrained' #103

Open wszhengjx opened 2 years ago

wszhengjx commented 2 years ago

Can you tell me the reason ,I will relly appreciate it !

Manteejike commented 2 years ago

What comment did you use? When I'm training,there is no argument pretrained

liuzhuang13 commented 2 years ago

Hi, can you copy the whole error message including function call stacks? This is very limited information

sowmyakavali commented 2 years ago

I am also getting the same issue . @liuzhuang13 The error is . ` Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/mmcv/utils/registry.py", line 66, in build_from_cfg return obj_cls(**args) TypeError: init() got an unexpected keyword argument 'pretrained'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/mmcv/utils/registry.py", line 66, in build_from_cfg return obj_cls(*args) File "/content/mmsegmentation/mmseg/models/segmentors/encoder_decoder.py", line 36, in init self.backbone = builder.build_backbone(backbone) File "/content/mmsegmentation/mmseg/models/builder.py", line 20, in build_backbone return BACKBONES.build(cfg) File "/usr/local/lib/python3.7/dist-packages/mmcv/utils/registry.py", line 234, in build return self.build_func(args, **kwargs, registry=self) File "/usr/local/lib/python3.7/dist-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/usr/local/lib/python3.7/dist-packages/mmcv/utils/registry.py", line 69, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') TypeError: ConvNeXt: init() got an unexpected keyword argument 'pretrained'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tools/train.py", line 252, in main() File "tools/train.py", line 207, in main cfg.model,) File "/content/mmsegmentation/mmseg/models/builder.py", line 50, in build_segmentor cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg)) File "/usr/local/lib/python3.7/dist-packages/mmcv/utils/registry.py", line 234, in build return self.build_func(*args, **kwargs, registry=self) File "/usr/local/lib/python3.7/dist-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/usr/local/lib/python3.7/dist-packages/mmcv/utils/registry.py", line 69, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') TypeError: EncoderDecoder: ConvNeXt: init() got an unexpected keyword argument 'pretrained'`

jrsykes commented 2 years ago

Just a guess... "Pretrained=True" is changing to "weights=ConvNeXt_Tiny_Weights.DEFAULT" in a new version of PyTorch.

For example:

from torchvision import models from torchvision.models import ConvNeXt_Tiny_Weights model_ft = models.convnext_tiny(weights=ConvNeXt_Tiny_Weights.DEFAULT)

See: https://pytorch.org/vision/main/models/generated/torchvision.models.convnext_tiny.html

Hope this helps.