wjc23 commited on
Commit
b0ef857
·
verified ·
1 Parent(s): e87bf5f

Create gradi

Browse files
Files changed (1) hide show
  1. gradi +40 -0
gradi ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Wed Apr 17 21:57:52 2024
4
+
5
+ @author: admin
6
+ """
7
+
8
+ import gradio as gr
9
+ import tensorflow as tf
10
+ import numpy as np
11
+
12
+ # 加载 TensorFlow 模型
13
+ model_path = 'model/model_CNN'
14
+ loaded_model = tf.saved_model.load(model_path)
15
+ model_predict = loaded_model.signatures['serving_default']
16
+ # 假设我们有一个处理这些输入的函数
17
+ def process_inputs(AMT, t, BSA, BW, age, height):
18
+ # 在这里执行您的逻辑,比如模型预测、计算等
19
+ input_features = np.array([[AMT, t, BSA, BW, age, height]], dtype=float).reshape(-1, 6, 1)
20
+ predictions = model_predict(tf.constant(input_features, dtype=tf.float32))['dense_5'].numpy()
21
+ return predictions
22
+
23
+ # 创建Gradio界面
24
+ description = "Enter values for AMT, t, BSA, BW, age, and height."
25
+ interface = gr.Interface(
26
+ fn=process_inputs,
27
+ inputs=[
28
+ gr.Number(label="AMT"),
29
+ gr.Number(label="t"),
30
+ gr.Number(label="BSA"),
31
+ gr.Number(label="BW"),
32
+ gr.Number(label="Age"),
33
+ gr.Number(label="Height")
34
+ ],
35
+ outputs="text",
36
+ description=description,
37
+ title="Input Processing Interface"
38
+ )
39
+
40
+ interface.launch()