Created
October 15, 2019 16:48
-
-
Save aymericdelab/e434024b887ae938399f63d54e136c27 to your computer and use it in GitHub Desktop.
entry point script for the deployment in azure ml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from tensorflow.contrib import predictor | |
from azureml.core.model import Model | |
import json | |
def init(): | |
global loaded_model | |
saved_model_location=Model.get_model_path('founder-classifier-test') | |
loaded_model = predictor.from_saved_model(saved_model_location) | |
def run(raw_data): | |
founders=['Bill Gates', 'Jeff Bezos', 'Larry Page'] | |
raw_data = np.array(json.loads(raw_data)['data']) | |
data=np.reshape((raw_data), (-1,28,28,1)) | |
predictions = loaded_model({'x': data})['classes'] | |
founder=founders[predictions[0]] | |
#return a serializable object | |
return str(founder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment