ium_444517/predict.py

18 lines
472 B
Python
Raw Normal View History

2022-05-15 12:41:28 +02:00
import json
import mlflow
import numpy as np
import sys
import tarfile
2022-05-15 12:55:35 +02:00
2022-05-15 12:41:28 +02:00
file = tarfile.open('mlruns.tar.gz')
file.extractall('./ml')
input = str((sys.argv[1:])[0])
PATH = "ml/mlruns/1/f65f936936024133a2c03e1e486ba9cf/artifacts/model/"
2022-05-15 12:56:40 +02:00
model =mlflow.pyfunc.load_model(f"{PATH}")
2022-05-15 12:41:28 +02:00
2022-05-15 12:57:28 +02:00
with open(f'{PATH}{input}', 'r') as file:
2022-05-15 12:41:28 +02:00
json_data = json.load(file)
2022-05-15 12:53:35 +02:00
2022-05-15 12:58:16 +02:00
print(f"Input: {json_data['inputs']}")
2022-05-15 13:00:29 +02:00
print(f"Prediction: {model.predict(np.array([json_data['inputs']]))}")