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

Training model cannot load properly #322

Open
SiruLiu645 opened this issue Oct 11, 2023 · 3 comments
Open

Training model cannot load properly #322

SiruLiu645 opened this issue Oct 11, 2023 · 3 comments

Comments

@SiruLiu645
Copy link

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.
image
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

@taishanglaojunya
Copy link

yes, I have the same problem!!! Do you have a solution now?

@ericspod
Copy link
Member

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.

@taishanglaojunya
Copy link

taishanglaojunya commented Jul 8, 2024 via email

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

3 participants