ium_s434700/predict-registry/predict.py
2021-06-10 14:59:48 +02:00

25 lines
673 B
Python

import json
import mlflow
import pandas as pd
from pprint import pprint
from mlflow.tracking import MlflowClient
model_name = "s430705"
model_version = 50
mlflow.set_tracking_uri("http://172.17.0.1:5000")
model = mlflow.keras.pyfunc.load_model(
model_uri=f"models:/{model_name}/{model_version}",
)
client = MlflowClient()
with open(client.get_model_version(model_name, model_version).source + '/input_example.json', 'r') as input_file:
data = json.load(input_file)
example_input = data["inputs"]
input_dictionary = {i: x for i, x in enumerate(example_input)}
input_ex = pd.DataFrame(input_dictionary, index=[0])
print("RESULT: ", model.predict(input_ex))