| 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 | |