ium_s434700/predict-registry/predict.py

25 lines
661 B
Python
Raw Normal View History

2021-06-08 18:32:35 +02:00
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}",
)
2021-06-10 14:45:52 +02:00
client = MlflowClient()
2021-06-10 14:58:09 +02:00
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(model.predict(input_ex))