File size: 699 Bytes
838f69f |
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 |
import numpy as np
from onnxruntime import InferenceSession
'''
входные данные data=[batch, 7]
shape=(1, 7) 7 входных параметров
'''
def softmax(x):
e_x = np.exp(x - np.max(x))
return e_x / e_x.sum(axis=0)
def predict(data):
model = InferenceSession("mymodel.onnx")
label=['норма', 'умеренные когнитивные', 'демнция']
input_data=np.array(data, dtype=np.float32).reshape(1,-1)
outputs = model.run(
output_names=["output"],
input_feed={"input": input_data},
)
dict_predict=dict(zip(label, softmax(outputs[0][0])))
return dict_predict
|