open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.28k stars 9.41k forks source link

TypeError: SwinTransformer: __init__() got an unexpected keyword argument 'pretrained' #5734

Closed myGithubSiki closed 3 years ago

myGithubSiki commented 3 years ago

hi when i change swim-transfromer as backbone of the detector , the detector is yolov5. i got this problem.

Traceback (most recent call last): File "/home/rpz/anaconda3/envs/swim_transformer_ryolov5_gwd/lib/python3.7/site-packages/mmcv/utils/registry.py", line 51, 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 "/home/rpz/anaconda3/envs/swim_transformer_ryolov5_gwd/lib/python3.7/site-packages/mmcv/utils/registry.py", line 51, in build_from_cfg return obj_cls(args) File "/home/rpz/rotmmdet-master/mmdetrot/models/detectors/single_stageR.py", line 10, in init super(SingleStageDetectorR, self).init(*args, *kwargs) File "/home/rpz/mmdet-yolov4-master/mmdet/models/detectors/single_stage.py", line 26, in init self.backbone = build_backbone(backbone) File "/home/rpz/mmdet-yolov4-master/mmdet/models/builder.py", line 19, in build_backbone return BACKBONES.build(cfg) File "/home/rpz/anaconda3/envs/swim_transformer_ryolov5_gwd/lib/python3.7/site-packages/mmcv/utils/registry.py", line 210, in build return self.build_func(args, kwargs, registry=self) File "/home/rpz/anaconda3/envs/swim_transformer_ryolov5_gwd/lib/python3.7/site-packages/mmcv/cnn/builder.py", line 26, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/rpz/anaconda3/envs/swim_transformer_ryolov5_gwd/lib/python3.7/site-packages/mmcv/utils/registry.py", line 54, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') TypeError: SwinTransformer: init() got an unexpected keyword argument 'pretrained'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/rpz/rotmmdet-master/tools/train.py", line 191, in main() File "/home/rpz/rotmmdet-master/tools/train.py", line 165, in main test_cfg=cfg.get('test_cfg')) File "/home/rpz/mmdet-yolov4-master/mmdet/models/builder.py", line 58, in build_detector cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg)) File "/home/rpz/anaconda3/envs/swim_transformer_ryolov5_gwd/lib/python3.7/site-packages/mmcv/utils/registry.py", line 210, in build return self.build_func(*args, **kwargs, registry=self) File "/home/rpz/anaconda3/envs/swim_transformer_ryolov5_gwd/lib/python3.7/site-packages/mmcv/cnn/builder.py", line 26, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/rpz/anaconda3/envs/swim_transformer_ryolov5_gwd/lib/python3.7/site-packages/mmcv/utils/registry.py", line 54, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') TypeError: SingleStageDetectorR: SwinTransformer: init() got an unexpected keyword argument 'pretrained'

can you help me solve this problem?

jshilong commented 3 years ago

Would your mind giving more details about your config and corresponding implementation about the swin-transformer

shinya7y commented 3 years ago

The same error as https://github.com/open-mmlab/mmdetection/issues/5392 . Code from the official swin should be updated for MMDetection >= 2.12.0.

ZwwWayne commented 3 years ago

See https://github.com/open-mmlab/mmdetection/pull/5748

jshilong commented 3 years ago

Feel free to reopen the issue if there is any question

neel04 commented 3 years ago

@jshilong I still have the same error - using master branch. It seems that when I try to use Resnet as backbone this errors occurs :(