ium_426206/mlflow_predict.py

17 lines
342 B
Python

import mlflow
import mlflow.pytorch
import sys
import json
import numpy as np
import torch
input = sys.argv[1]
model = mlflow.pytorch.load_model("my_model")
with open('my_model/'+input) as json_file:
data = json.load(json_file)
#print(np.array(data['inputs']))
print(model(torch.tensor(np.array(data['inputs'])).float()))