ium_434704/mlflow_prediction.py

18 lines
352 B
Python
Raw Normal View History

2021-05-23 16:21:50 +02:00
import json
import mlflow
import pandas as pd
import sys
arguments = sys.argv[1:]
input = str(arguments[0])
2021-05-23 17:04:25 +02:00
model = mlflow.pytorch.load_model("my_model")
2021-05-23 16:21:50 +02:00
2021-05-23 17:28:57 +02:00
with open(f'my_model/{input}', 'r') as file:
2021-05-23 16:21:50 +02:00
json_data = json.load(file)['inputs']
data_into_dict = {idx:x for idx, x in enumerate(json_data)}
2021-05-23 17:44:24 +02:00
print(model(pd.DataFrame([data_into_dict])))