RuntimeError: Error(s) in loading state_dict for FasterRCNN
See original GitHub issueI’ve saved a model using model.save('model_weights.pth')
after a successful run.
When now attempting to load the model using the code;
from detecto.core import Model
model = Model.load('model_weights.pth', ['aboriginalflags'])
I get the error
Traceback (most recent call last):
File "show.py", line 5, in <module>
model = Model.load('model_weights.pth', ['aboriginalflags'])
File "/usr/local/lib/python3.8/dist-packages/detecto/core.py", line 566, in load
model._model.load_state_dict(torch.load(file, map_location=model._device))
File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1044, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for FasterRCNN:
size mismatch for roi_heads.box_predictor.cls_score.weight: copying a param with shape torch.Size([3, 1024]) from checkpoint, the shape in current model is torch.Size([2, 1024]).
size mismatch for roi_heads.box_predictor.cls_score.bias: copying a param with shape torch.Size([3]) from checkpoint, the shape in current model is torch.Size([2]).
size mismatch for roi_heads.box_predictor.bbox_pred.weight: copying a param with shape torch.Size([12, 1024]) from checkpoint, the shape in current model is torch.Size([8, 1024]).
size mismatch for roi_heads.box_predictor.bbox_pred.bias: copying a param with shape torch.Size([12]) from checkpoint, the shape in current model is torch.Size([8]).
Ubuntu 20
(loving the lib, great work)
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
PyTorch - RuntimeError: Error(s) in loading state_dict for VGG
The problem is that what is being saved is not the same as what is expected to be loaded. The code is trying...
Read more >RuntimeError: Error(s) in loading state_dict for FasterRCNN
Problem description RuntimeError: Error(s) in loading state_dict for FasterRCNN:Missing key(s) in state_dict: “backbone.body.conv1.weight”, “backbone.body.bn1. ...
Read more >RuntimeError: Error(s) in loading state_dict for DataParallel
Hi, I have reimplemented the GAN for grayscale radiology data using the following Github Repo: GitHub - mdraw/BMSG-GAN at img_channels I ...
Read more >RuntimeError: Error(s) in loading state_dict for FasterRCNN
Problem description. RuntimeError: Error(s) in loading state_dict for FasterRCNN:Missing key(s) in state_dict: “backbone.body.conv1.weight”, ...
Read more >[Solution][Pytorch] RuntimeError: Error(s) in loading state_dict for
다를 수 있지만 저에게 있어 해당 문제는 다중 GPU를 사용하고자 torch.nn.DataParallel를 사용하면서 생긴 문제라고 판단했습니다. nn.DataParallel 모델 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Were you able to solve the issue ? Could you share how you did it?
Is it still the problem ?