segmentation_models.pytorch icon indicating copy to clipboard operation
segmentation_models.pytorch copied to clipboard

Cannot import trained model

Open NyanSwanAung opened this issue 3 years ago • 3 comments

I have trained two unet++ models and the model format is in .pth. A few days ago I can load the model but now I cannot load it anymore.

I used torch.save(model, model_full_path) to save the model and torch.load(model_full_path) to load the model.

It is giving me two errors for each model.

1st model name - unetplusplus-1.pth error - RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

2nd model name - unetplusplus-2.pth error - ModuleNotFoundError: No module named 'segmentation_models_pytorch.unetplusplus'

Versions Pytorch - 1.12.1+cu102 SMP - 0.3.0

Here's the link for model weights.

NyanSwanAung avatar Aug 06 '22 09:08 NyanSwanAung

I am also facing this error, may be because of new release 0.3.0?

ppm3012 avatar Aug 06 '22 10:08 ppm3012

Yes, downgrade to previous version please to load the model. You can save weights only, and it will work across different versions

qubvel avatar Aug 06 '22 11:08 qubvel

@qubvel downgrading to the previous version solved the ModuleNotFoundError but I'm still facing the RuntimeError.

ppm3012 avatar Aug 06 '22 14:08 ppm3012

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Oct 06 '22 02:10 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Oct 13 '22 02:10 github-actions[bot]

I am reopening since the error is still occuring while loadind trained model

ModuleNotFoundError: No module named 'segmentation_models_pytorch.unet'

SMP: 0.3.2 Pytorch: 1.10

giorgionicola avatar Feb 23 '23 10:02 giorgionicola