open-mmlab / mmdetection

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

KeyError: 'backbone.stages.0.blocks.0.attn.w_msa.relative_position_bias_table' #7176

Closed Williamlizl closed 2 years ago

Williamlizl commented 2 years ago

I run the commond it shows the error:

CUDA_VISIBLE_DEVICES=0,1,2,3 ./tools/dist_train.sh configs/swin/mask_rcnn_swin-s-p4-w7_fpn_fp16_ms-crop-3x_coco.py 4

`Traceback (most recent call last): File "./tools/train.py", line 189, in Traceback (most recent call last): Traceback (most recent call last): Traceback (most recent call last): File "./tools/train.py", line 189, in File "./tools/train.py", line 189, in File "./tools/train.py", line 189, in main() File "./tools/train.py", line 163, in main main()main()main()

File "./tools/train.py", line 163, in main File "./tools/train.py", line 163, in main File "./tools/train.py", line 163, in main model.init_weights() File "/home/lbc/.local/lib/python3.7/site-packages/mmcv/runner/base_module.py", line 117, in init_weights model.init_weights()model.init_weights()

model.init_weights() File "/home/lbc/.local/lib/python3.7/site-packages/mmcv/runner/base_module.py", line 117, in init_weights

File "/home/lbc/.local/lib/python3.7/site-packages/mmcv/runner/base_module.py", line 117, in init_weights File "/home/lbc/.local/lib/python3.7/site-packages/mmcv/runner/base_module.py", line 117, in init_weights m.init_weights() File "/home/lbc/mmdetection-master/mmdet/models/backbones/swin.py", line 727, in init_weights m.init_weights()m.init_weights()

m.init_weights() File "/home/lbc/mmdetection-master/mmdet/models/backbones/swin.py", line 727, in init_weights File "/home/lbc/mmdetection-master/mmdet/models/backbones/swin.py", line 727, in init_weights

File "/home/lbc/mmdetection-master/mmdet/models/backbones/swin.py", line 727, in init_weights table_current = self.state_dict()[table_key] KeyError: 'backbone.stages.0.blocks.0.attn.w_msa.relative_position_bias_table' table_current = self.state_dict()[table_key]table_current = self.state_dict()[table_key]

table_current = self.state_dict()[table_key]KeyErrorKeyError

: : 'backbone.stages.0.blocks.0.attn.w_msa.relative_position_bias_table''backbone.stages.0.blocks.0.attn.w_msa.relative_position_bias_table'KeyError

: 'backbone.stages.0.blocks.0.attn.w_msa.relative_position_bias_table' Traceback (most recent call last): File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/lbc/.local/lib/python3.7/site-packages/torch/distributed/launch.py", line 260, in main() File "/home/lbc/.local/lib/python3.7/site-packages/torch/distributed/launch.py", line 256, in main cmd=cmd) subprocess.CalledProcessError: Command '['/usr/local/bin/python3.7', '-u', './tools/train.py', '--local_rank=3', 'configs/swin/mask_rcnn_swin-s-p4-w7_fpn_fp16_ms-crop-3x_coco.py', '--launcher', 'pytorch']' returned non-zero exit status 1`

`pretrained = './pretrained/mask_rcnn_swin-s-p4-w7_fpn_fp16_ms-crop-3x_coco_20210903_104808-b92c91f1.pth'

shinya7y commented 2 years ago

To use COCO pre-trained weights, load_from = './pretrained/mask_rcnn_swin-s-p4-w7_fpn_fp16_ms-crop-3x_coco_20210903_104808-b92c91f1.pth' instead of pretrained.