Facing problem in loaded model from colab notebook to flask app #707
Replies: 2 comments
-
Hello! It sounds like you’re experiencing an issue with loading a PyTorch model that you trained in a Colab notebook into a Flask app. Specifically, you mentioned that the model is redownloading the dataset and retraining itself when you load it using torch.load(). One possible reason for this behavior is that the model is not being loaded correctly. When you save a PyTorch model using torch.save(), it saves the model’s state dictionary to a file. To load the model back into memory, you need to create an instance of the model and then load the state dictionary into it using model.load_state_dict(). Here’s an example of how you can do this:
In this example, we first create an instance of the model using I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Thank you shisirkha !!
… |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello team,i have created PetsImageclassificarion model using pytirch in colab notebook and saved
with
torch.save(model,path)
And downloade dmodel and loaded using torch.load()in flask app but it started redownloading dataset and retraining model again in flask app in vscode terminal
Beta Was this translation helpful? Give feedback.
All reactions