Skip to content

Fix Bug for Loading Non Default Model #123

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions detecto/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def save(self, file):
torch.save(self._model.state_dict(), file)

@staticmethod
def load(file, classes):
def load(file, classes, model_name=DEFAULT):
"""Loads a model from a .pth file containing the model weights.

:param file: The path to the .pth file containing the saved model.
Expand All @@ -613,7 +613,7 @@ def load(file, classes):
>>> model = Model.load('model_weights.pth', ['ant', 'bee'])
"""

model = Model(classes)
model = Model(classes, model_name=model_name)
model._model.load_state_dict(torch.load(file, map_location=model._device))
return model

Expand Down