Open SiruLiu645 opened 9 months ago
yes, I have the same problem!!! Do you have a solution now?
Hi both, sorry for the lateness of reply. I think the latter case when you're loading from the "state_dict" key is the correct thing to do, however the model that you've instantiated has different constructor arguments from the model that these weights were saved from. You'll need to figure out what the parameters were exactly and be sure your class is instantiated correctly, if your weights are very old it's possible the class definition has changed and you may have to get the old version of the code from a previous MONAI release on Github and copy that into your project.
谢谢你的提示!
Eric Kerfoot @.***> 于2024年6月10日周一 19:42写道:
Hi both, sorry for the lateness of reply. I think the latter case when you're loading from the "state_dict" key is the correct thing to do, however the model that you've instantiated has different constructor arguments from the model that these weights were saved from. You'll need to figure out what the parameters were exactly and be sure your class is instantiated correctly, if your weights are very old it's possible the class definition has changed and you may have to get the old version of the code from a previous MONAI release on Github and copy that into your project.
— Reply to this email directly, view it on GitHub https://github.com/Project-MONAI/research-contributions/issues/322#issuecomment-2158118277, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDN4R34OE7NQB46IDWASUTTZGWGMFAVCNFSM6AAAAABJBXKC5WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJYGEYTQMRXG4 . You are receiving this because you commented.Message ID: @.***>
I use a heart CT dataset to train this model,and I save this model when loss decrease to 0.7. However, I cannot load this pretrained model when I run test.py.
Then I changed the code "model_dict = torch.load(pretrained_pth)" to "model_dict = torch.load(pretrained_pth)["state_dict"]", it came to another problem:
![image](https://github.com/Project-MONAI/research-contributions/assets/116564427/09f3d4a3-7ddf-462b-85dc-2742f24ee830)