Last active
September 22, 2022 05:05
-
-
Save tabsciy/8998b4a4f7bf42dcc7bea4806e44b954 to your computer and use it in GitHub Desktop.
hello world example with loaded state example 2
This file contains 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
from Algorithmia import ADK | |
import Algorithmia | |
import pickle | |
client = Algorithmia.client() | |
def load_model(file_path): | |
model_path = client.file(file_path).getFile().name | |
with open(model_path, 'rb') as f: | |
model = pickle.load(f) | |
return model | |
# my_model.pkl is a dict with key 'metadata' | |
def load(modelData): | |
modelData['my_model'] = load_model('data://fws/test/my_model.pkl') | |
return modelData | |
def apply(input, modelData): | |
return "hello {} {}".format(str(input), str(modelData['my_model']['metadata'])) | |
algorithm = ADK(apply, load) | |
algorithm.init("Algorithmia") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment