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
AttributeError: 'Model' object has no attribute 'state_dict' #72
Comments
You should be able to save the weights by using |
@alankbi thank you for the quick reply! |
Are you running that on the Detecto model or the internal model? If it's the Detecto model, try getting the internal PyTorch model using |
I did try your solution, but got a similar error! Could you please suggest a suitable solution? |
Could you share the code? It seems like you're calling these methods on the wrong object but it'd be helpful to reference the code to figure out exactly where this is happening. |
This is the code which we wrote for testing! |
You should change this line: model = torch.load('model.pth', map_location = 'cpu') to this: from detecto.core import Model
classes = [<insert list of classes/labels here>]
model = Model.load('model.pth', classes) Then, internal_model = model.get_internal_model()
internal_model.eval()
... However, if you're using Detecto's |
Thank you! This worked for me. |
@alankbi import tempfile #save the prediction dataframe after training and compare with prediction after reload checkpoint #Create a trainer to make a checkpoint m.trainer.save_checkpoint("/content/checkpoint.pl",format(tmpdir))#reload the checkpoint to model object assert not pred_after_train.empty |
While saving the best weights, I am facing this error.
torch.save(model.state_dict, 'checkpoint.pth')
Environment: Google Colab
Could you please suggest a corrective measure for this error!
The text was updated successfully, but these errors were encountered: