ium_426206/mlflow_predict_registry.py

22 lines
649 B
Python
Raw Normal View History

2021-05-23 19:01:11 +02:00
from mlflow.tracking import MlflowClient
2021-05-23 19:47:55 +02:00
import mlflow
import mlflow.keras
2021-05-23 19:01:11 +02:00
import json
#mlflow.set_tracking_uri("http://127.0.0.1:5000")
mlflow.set_tracking_uri("http://172.17.0.1:5000")
client = MlflowClient()
version = 0
2021-05-23 19:47:55 +02:00
model_name = "s434704"
for mv in client.search_model_versions(f"name='{model_name}'"):
2021-05-23 19:01:11 +02:00
if int(mv.version) > version:
version = int(mv.version)
model = mlflow.pytorch.load_model(
model_uri=f"models:/{model_name}/{version}"
)
2021-05-23 19:47:55 +02:00
with open('movies_on_streaming_platforms_model/input_example.json') as json_file:
2021-05-23 19:01:11 +02:00
data = json.load(json_file)
#print(np.array(data['inputs']))
2021-05-23 19:47:55 +02:00
print(model.predict(data['inputs']))