Skip to content

Update hubconf.py #2

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: main
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
9 changes: 7 additions & 2 deletions hubconf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# import the necessary packages
import torch
from pyimagesearch import mlp
import os

# define entry point/callable function
# to initialize and return model
Expand All @@ -13,6 +14,10 @@ def custom_model():
# initialize the model
# load weights from path
# returns model
repo_dir = os.path.dirname(__file__)
model = mlp.get_training_model()
model.load_state_dict(torch.load("model_wt.pth"))
return model
model_path = os.path.join(repo_dir, "output", "model_wt.pth")
if not os.path.exists(model_path):
raise FileNotFoundError(f"Model file not found at {model_path}")
model.load_state_dict(torch.load(model_path))
return model