Closed 1640477469 closed 2 years ago
Hi @1640477469
It is most likely a mismatch between your Pytorch/MONAI version and specified dependencies in this repository.
Thanks
Hi @1640477469,
I faced the same problem with UNETR models trained using the repository. Did you find any solution?
Thank you.
Same issue with me, I am not able to load my own trained model. Could somebody work it out please?
@Jamshidhsp,
I solved it by modifying the line in UNETR/BTCV/trainer.py that saves the model as,
torch.save(model.state_dict(), filename)
. Provide the filename as model.pth
instead of model.pt
.
Thank you.
@hanoonaR Thank you very much. I did it and now, I am facing the error: RuntimeError: PytorchStreamReader failed locating file constants.pkl: file not found
Could you manage it? Thanks
@Jamshidhsp, Yes I faced the same issue and had to retrain the model and save it in the above mentioned way, in .pth
form. The issue was then resolved. Thank you.
@hanoonaR Thank you again. I am gonna retrain again!
@hanoonaR Thank you very much for your help. Actually I tried to get over it. I used the same version of pytorch and monai, changed model from .pt to .pth. But at the end, I face the error again. I am wondering the problem arises from python version or protobuf version. Could you please check the version of protobuf/python you used? I really appreciate it. Thanks
HI @Jamshidhsp ,
Sure. Please find the environment details: python: 3.8.13 protobuf: 3.19.4 torch: 1.9.1+cu111 monai: 0.7.0 nibabel: 3.1.1
PS: Please note that the command to save model is modified from torch.save(save_dict, filename)
to torch.save(model.state_dict(), filename)
.
Hope it helps. Thank you.
@hanoonaR Thank you for the details and your help. It didn't work, but very useful. I will try finding it out.
@hanoonaR I saw you edited the message on saving the model. It works now! You helped a lot. I really appreciate it!
when i use UNETR_model_best_acc.pt,i can get the result,but when i use my own model.pt,there have RuntimeError: PytorchStreamReader failed locating file constants.pkl: file not found.how can i solve it?