update samples from Release-93 as a part of SDK release
This commit is contained in:
21
tutorials/quickstart-ci/score.py
Normal file
21
tutorials/quickstart-ci/score.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import json
|
||||
import numpy as np
|
||||
import os
|
||||
import joblib
|
||||
|
||||
|
||||
def init():
|
||||
global model
|
||||
# AZUREML_MODEL_DIR is an environment variable created during deployment.
|
||||
# It is the path to the model folder (./azureml-models/$MODEL_NAME/$VERSION)
|
||||
# For multiple models, it points to the folder containing all deployed models (./azureml-models)
|
||||
model_path = os.path.join(os.getenv("AZUREML_MODEL_DIR"), "sklearn_mnist_model.pkl")
|
||||
model = joblib.load(model_path)
|
||||
|
||||
|
||||
def run(raw_data):
|
||||
data = np.array(json.loads(raw_data)["data"])
|
||||
# make prediction
|
||||
y_hat = model.predict(data)
|
||||
# you can return any data type as long as it is JSON-serializable
|
||||
return y_hat.tolist()
|
||||
Reference in New Issue
Block a user