jinyin_chen
commited on
Commit
·
070f7a9
1
Parent(s):
4334a37
ui test
Browse files- app.py +9 -5
- images/uploaded_20240909101256.png +0 -0
- images/uploaded_20240909101711.png +0 -0
- images/uploaded_20240909101712.png +0 -0
- images/uploaded_20240909102000.png +0 -0
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
|
|
|
|
3 |
|
4 |
def process_image(image):
|
5 |
# 设置保存图片的路径,指向当前工程的 images 目录
|
@@ -15,17 +17,19 @@ def process_image(image):
|
|
15 |
|
16 |
# 保存图片
|
17 |
image.save(image_path)
|
18 |
-
|
19 |
-
|
|
|
|
|
20 |
|
21 |
# 定义输入:一个图片选择框
|
22 |
-
|
23 |
|
24 |
# 定义输出:一个文本框,用来显示确认信息或处理结果
|
25 |
-
|
26 |
|
27 |
# 创建 Interface 对象,设置 live=False 以添加提交按钮
|
28 |
-
demo = gr.Interface(fn=process_image, inputs=
|
29 |
|
30 |
# 启动界面
|
31 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
from main_infer import INFER_API
|
4 |
+
|
5 |
|
6 |
def process_image(image):
|
7 |
# 设置保存图片的路径,指向当前工程的 images 目录
|
|
|
17 |
|
18 |
# 保存图片
|
19 |
image.save(image_path)
|
20 |
+
infer_api = INFER_API()
|
21 |
+
score = infer_api.test(img_path)
|
22 |
+
|
23 |
+
return f"图片已保存至 {image_path},得分是:{score}" # 返回保存的位置信息
|
24 |
|
25 |
# 定义输入:一个图片选择框
|
26 |
+
image_input = gr.components.Image(label="Upload Image", type="pil")
|
27 |
|
28 |
# 定义输出:一个文本框,用来显示确认信息或处理结果
|
29 |
+
text_output = gr.components.Textbox()
|
30 |
|
31 |
# 创建 Interface 对象,设置 live=False 以添加提交按钮
|
32 |
+
demo = gr.Interface(fn=process_image, inputs=image_input, outputs=text_output, live=False)
|
33 |
|
34 |
# 启动界面
|
35 |
demo.launch()
|
images/uploaded_20240909101256.png
ADDED
images/uploaded_20240909101711.png
ADDED
images/uploaded_20240909101712.png
ADDED
images/uploaded_20240909102000.png
ADDED
requirements.txt
CHANGED
@@ -16,4 +16,4 @@ uvicorn==0.22.0
|
|
16 |
pydantic==1.10.9
|
17 |
torch==1.13.1
|
18 |
torchvision==0.14.1
|
19 |
-
|
|
|
16 |
pydantic==1.10.9
|
17 |
torch==1.13.1
|
18 |
torchvision==0.14.1
|
19 |
+
gradio
|