ium_444517/predict.py
2022-05-15 12:58:16 +02:00

18 lines
490 B
Python

import json
import mlflow
import numpy as np
import sys
import tarfile
file = tarfile.open('mlruns.tar.gz')
file.extractall('./ml')
input = str((sys.argv[1:])[0])
PATH = "ml/mlruns/1/f65f936936024133a2c03e1e486ba9cf/artifacts/model/"
model =mlflow.pyfunc.load_model(f"{PATH}")
with open(f'{PATH}{input}', 'r') as file:
json_data = json.load(file)
print(f"Input: {json_data['inputs']}")
print(f"Prediction: {model.predict(np.array([json_data['inputs']], dtype=np.float32))}")