-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathonnx_predict.py
37 lines (31 loc) · 1.05 KB
/
onnx_predict.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pandas as pd
import click
import mlflow
import mlflow.pyfunc
import mlflow.onnx
import utils
import onnx_utils
utils.display_versions()
@click.command()
@click.option("--model-uri", help="Model URI", required=True, type=str)
def main(model_uri):
print("model_uri:", model_uri)
data = utils.get_prediction_data()
print("\n**** mlflow.onnx.load_model\n")
model = mlflow.onnx.load_model(model_uri)
print("model.type:", type(model))
predictions = onnx_utils.score_model(model, data)
print("predictions.type:",type(predictions))
print("predictions.shape:",predictions.shape)
print("predictions:",predictions)
utils.predict_pyfunc(model_uri, data)
print("\n**** mlflow.pyfunc.load_model\n")
model = mlflow.pyfunc.load_model(model_uri)
print("model.type:", type(model))
data = pd.DataFrame(data)
predictions = model.predict(data)
print("predictions.type:", type(predictions))
print("predictions.shape:", predictions.shape)
print("predictions:", predictions)
if __name__ == "__main__":
main()