Skip to content

Instantly share code, notes, and snippets.

@aymericdelab
Created October 15, 2019 16:48
Show Gist options
  • Save aymericdelab/e434024b887ae938399f63d54e136c27 to your computer and use it in GitHub Desktop.
Save aymericdelab/e434024b887ae938399f63d54e136c27 to your computer and use it in GitHub Desktop.
entry point script for the deployment in azure ml
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