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

Loading custom models #76

Open
saninta0212 opened this issue Oct 22, 2024 · 3 comments
Open

Loading custom models #76

saninta0212 opened this issue Oct 22, 2024 · 3 comments

Comments

@saninta0212
Copy link

Hi all, is there a way for me to load custom models given a path if the model is not present in the model zoo?

@avantikalal
Copy link
Collaborator

Yes you can use

from grelu.lightning import LightningModel
model = LightningModel.load_from_checkpoint(file)

However, the model checkpoint has to be saved using gReLU. We currently don't have the ability to load arbitrary pytorch models, though we will add more flexibility in this direction soon.

@saninta0212
Copy link
Author

After I load a model for eg using model = grelu.resources.load_model(
project=project_name,
model_name='model'
)

How can I save this model into a checkpoint that can be loaded later?

@avantikalal
Copy link
Collaborator

Here is a hacky snippet that works for me, though it isn't ideal.

import pytorch_lightning as pl
trainer = pl.Trainer()
try:
    trainer.predict(model)
except:
    pass
trainer.save_checkpoint(file_path)

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