Open sathyz opened 7 years ago
What do docker logs say? (e.g. docker logs
I just tested the digit_classification sample and got the same error. [500 Internal Server Error]. It looks like the underlying flask app can't deserialize the Numpy array, it simply passes a JSON string through.
#%%writefile main.py
#The init and run functions will load and score your input using the saved model.
#They will also be used to generate the main.py script which will be part of your create service call.
def init():
# read in the model file
from sklearn.externals import joblib
global model
model = joblib.load('sklearn/model.pkl')
print("init done.")
def run(input_array):
import json
import numpy as np
if(type(input_array) == str):
input_json = json.loads(input_array)
input_array = np.array(input_json["input_array"])
if (input_array.shape != (1, 64)):
return 'Bad input: Expecting a json encoded list of lists of shape (1,64).'
else:
pred = model.predict(input_array)[0]
print("init run.")
return json.dumps(str(pred))
Following the steps in samples/python/tutorials/realtime/digit_classification.ipynb, I have created the model. Tests on DSVM passes.
I'm getting the following error on sending request to the service,