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

Upload 2 files

Browse files
Files changed (2) hide show
  1. gradi.py +40 -0
  2. model.zip +3 -0
gradi.py 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()
model.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83ca484cc4bc70aec34d97563b2b9c1e37e4dff20a16014cde6b161d6a9b87d5
3
+ size 1048745