| |
| """ |
| Created on Wed Apr 17 21:57:52 2024 |
|
|
| @author: admin |
| """ |
|
|
| import gradio as gr |
| import tensorflow as tf |
| import numpy as np |
|
|
| |
| model_path = 'model/model_CNN' |
| loaded_model = tf.saved_model.load(model_path) |
| model_predict = loaded_model.signatures['serving_default'] |
| |
| def process_inputs(AMT, t, BSA, BW, age, height): |
| # 在这里执行您的逻辑,比如模型预测、计算等 |
| input_features = np.array([[AMT, t, BSA, BW, age, height]], dtype=float).reshape(-1, 6, 1) |
| predictions = model_predict(tf.constant(input_features, dtype=tf.float32))['dense_5'].numpy() |
| return predictions |
| |
| |
| description = "Enter values for AMT, t, BSA, BW, age, and height." |
| interface = gr.Interface( |
| fn=process_inputs, |
| inputs=[ |
| gr.Number(label="AMT"), |
| gr.Number(label="t"), |
| gr.Number(label="BSA"), |
| gr.Number(label="BW"), |
| gr.Number(label="Age"), |
| gr.Number(label="Height") |
| ], |
| outputs="text", |
| description=description, |
| title="Input Processing Interface" |
| ) |
| |
| interface.launch() |