Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

移植到mmengine 2.*, model加载问题 #93

Open
yuanxuanS opened this issue Feb 6, 2024 · 1 comment
Open

移植到mmengine 2.*, model加载问题 #93

yuanxuanS opened this issue Feb 6, 2024 · 1 comment

Comments

@yuanxuanS
Copy link

我想将代码移植到mmengine 2.*版本,但是mmengine中取消了MMDataParallel, 我换成了torch.nn.DataParallel.
在加载模型的时候会报错: File "./tools/train.py", line 104, in
main()
File "./tools/train.py", line 100, in main
runner.train()
File "/root/miniconda3/lib/python3.8/site-packages/mmengine/runner/runner.py", line 1748, in train
self._init_model_weights()
File "/root/miniconda3/lib/python3.8/site-packages/mmengine/runner/runner.py", line 923, in _init_model_weights
model.init_weights()
File "/root/miniconda3/lib/python3.8/site-packages/mmengine/model/base_module.py", line 136, in init_weights
m.init_weights()
File "/root/mmseg/mmseg/models/backbones/vit_bimla.py", line 339, in init_weights
load_pretrained(self, num_classes=self.num_classes, in_chans=self.in_chans, pos_embed_interp=self.pos_embed_interp, num_patches=self.patch_embed.num_patches, align_corners=self.align_corners)
File "/root/mmseg/mmseg/models/backbones/helpers.py", line 60, in load_pretrained
state_dict = torch.load(cfg['pretrained_finetune'])
File "/root/miniconda3/lib/python3.8/site-packages/torch/serialization.py", line 713, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/root/miniconda3/lib/python3.8/site-packages/torch/serialization.py", line 938, in _legacy_load
typed_storage._storage._set_from_file(
RuntimeError: storage has wrong byte size: expected %ld got %ld04096

加载的是pretrain/jx_vit_large_p16_384-b3be5167.pth

@MengyangPu
Copy link
Owner

Hi @yuanxuanS ,
Sorry, I don't know how to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants