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

Where are storing the trained model #1

Open
shersoni610 opened this issue Sep 1, 2023 · 2 comments
Open

Where are storing the trained model #1

shersoni610 opened this issue Sep 1, 2023 · 2 comments

Comments

@shersoni610
Copy link

Hello,

Can you please explain how to store the trained model and how to use it?

@ariawoo
Copy link

ariawoo commented Oct 2, 2023

Code to save the model :
torch.save({
'epoch': epoch,
'model_state_dict': model.state_dict(),
'optimizer_state_dict': optimizer.state_dict(),
'loss': total_loss,
}, f"model_checkpoint/model_10.pt") #just change to your preferred folder/filename

Code to load the saved model :
model, preprocess = clip.load("ViT-B/32",device=device,jit=False) #Must set jit=False for training
checkpoint = torch.load("model_checkpoint/model_10.pt")
model.load_state_dict(checkpoint['model_state_dict'])

For more information, @shersoni610 you can visit here. openai/CLIP#83

@rajasblack
Copy link

How about evaluation and inference? TIA @Coffeyliu

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