ium_426206/mlflow_predict_registry.py

22 lines
649 B
Python

from mlflow.tracking import MlflowClient
import mlflow
import mlflow.keras
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
model_name = "s434704"
for mv in client.search_model_versions(f"name='{model_name}'"):
if int(mv.version) > version:
version = int(mv.version)
model = mlflow.pytorch.load_model(
model_uri=f"models:/{model_name}/{version}"
)
with open('movies_on_streaming_platforms_model/input_example.json') as json_file:
data = json.load(json_file)
#print(np.array(data['inputs']))
print(model.predict(data['inputs']))