Open NEUdeep opened 3 years ago
I know.
If you found the solution please share it for the benefit of others.
Seems like the pretrained weights expects the model to have an explicit backbone layer since all of the weights for the backbone have 'backbone' in them. I simply removed the backbone.
from all the keys in the weight dictionary and manually loaded the weights. Maybe another way to solve this is to make a nn.Module
object with self.backbone = SwinTransformer(...)
may caused by difference between setting "window_size=7" in Swin classification model and mmdetection config
2021-06-01 01:32:06,714 - mmdet - INFO - load model from: checkpoints/cascade_mask_rcnn_swin_base_patch4_window7.pth Traceback (most recent call last): File "tools/train.py", line 187, in
main()
File "tools/train.py", line 161, in main
test_cfg=cfg.get('test_cfg'))
File "/workspace/mnt/storage/kanghaidong/cloud_project/Swin-Transformer-Object-Detection/mmdet/models/builder.py", line 77, in build_detector
return build(cfg, DETECTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg))
File "/workspace/mnt/storage/kanghaidong/cloud_project/Swin-Transformer-Object-Detection/mmdet/models/builder.py", line 34, in build
return build_from_cfg(cfg, registry, default_args)
File "/usr/local/lib/python3.6/dist-packages/mmcv/utils/registry.py", line 171, in build_from_cfg
return obj_cls(**args)
File "/workspace/mnt/storage/kanghaidong/cloud_project/Swin-Transformer-Object-Detection/mmdet/models/detectors/cascade_rcnn.py", line 25, in init
pretrained=pretrained)
File "/workspace/mnt/storage/kanghaidong/cloud_project/Swin-Transformer-Object-Detection/mmdet/models/detectors/two_stage.py", line 48, in init
self.init_weights(pretrained=pretrained)
File "/workspace/mnt/storage/kanghaidong/cloud_project/Swin-Transformer-Object-Detection/mmdet/models/detectors/two_stage.py", line 68, in init_weights
self.backbone.init_weights(pretrained=pretrained)
File "/workspace/mnt/storage/kanghaidong/cloud_project/Swin-Transformer-Object-Detection/mmdet/models/backbones/swin_transformer.py", line 595, in init_weights
load_checkpoint(self, pretrained, strict=False, logger=logger)
File "/workspace/mnt/storage/kanghaidong/cloud_project/Swin-Transformer-Object-Detection/mmcv_custom/checkpoint.py", line 340, in load_checkpoint
table_current = model.state_dict()[table_key]
KeyError: 'backbone.layers.0.blocks.0.attn.relative_position_bias_table'
pytorch==1.7.0 is any pre-trained weight error? can you provide a swin_transformer pre-trained model's.thanks.