Skip to content

How to migrate existing models from 0.4.0 to 0.5.0? #1144

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

Open
ChristianWiele opened this issue May 5, 2025 · 4 comments
Open

How to migrate existing models from 0.4.0 to 0.5.0? #1144

ChristianWiele opened this issue May 5, 2025 · 4 comments

Comments

@ChristianWiele
Copy link

Hi,

I trained a lot of models on version 0.4.0. After upgrade to 0.5.0 I can't load them anymore, as I get errors like

AttributeError: Can't get attribute 'DecoderBlock' on <module 'segmentation_models_pytorch.decoders.unet.decoder' from '/home/christian/dev/HSP/libraries/atnc_mcv/venv/lib/python3.12/site-packages/segmentation_models_pytorch/decoders/unet/decoder.py'>

So, how can I keep using my trained models with the new version?

Thanks, Christian

@qubvel
Copy link
Collaborator

qubvel commented May 5, 2025

Hi @ChristianWiele, it depends on the models you have trained. state_dicts should be backward compatible, so saving weights in 0.4.0 and loading them in 0.5.0 should work. In case you save the entire model (troch.save(model)), I would recommend loading it in v 0.4.0, saving with save_pretrained and then loading in 0.5.0 with from_pretrained - this should work.

@qubvel
Copy link
Collaborator

qubvel commented May 5, 2025

Sorry for the inconvenience 🤗 that's the way to bring new features to the library

@ChristianWiele
Copy link
Author

Hi @qubvel, thanks for the quick response. This seems to work. I use mlflow to save my models which uses torch.save() . I guess there is no direct way to use save_pretrained with mlflow!?

@qubvel
Copy link
Collaborator

qubvel commented May 5, 2025

I'm not very familiar with MLflow, not sure if there is a direct way to do that. However, I hope some callbacks exist to override the default behaviour.

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

2 participants