Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
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
18 changes: 8 additions & 10 deletions 18 diabetes_regression/scoring/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import numpy
import joblib
import os
from azureml.core.model import Model
from inference_schema.schema_decorators \
import input_schema, output_schema
from inference_schema.parameter_types.numpy_parameter_type \
Expand All @@ -36,16 +37,13 @@ def init():
# load the model from file into a global object
global model

# AZUREML_MODEL_DIR is an environment variable created during service
# deployment. It contains the path to the folder containing the model.
path = os.environ['AZUREML_MODEL_DIR']
model_path = None
for root, dirs, files in os.walk(path):
for file in files:
if '.pkl' in file:
model_path = os.path.join(path, file)
if model_path is None:
raise ValueError(".pkl model not found")
# we assume that we have just one model
# AZUREML_MODEL_DIR is an environment variable created during deployment.
# It is the path to the model folder
# (./azureml-models/$MODEL_NAME/$VERSION)
model_path = Model.get_model_path(
os.getenv("AZUREML_MODEL_DIR").split('/')[-2])

model = joblib.load(model_path)


Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.