Skip to content
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