Spaces:
Sleeping
Sleeping
zxcvb6958 commited on
Commit ·
6321e70
1
Parent(s): 9ea642a
update UI
Browse files
app.py
CHANGED
|
@@ -3,7 +3,6 @@ from PIL import Image
|
|
| 3 |
import os
|
| 4 |
import random
|
| 5 |
|
| 6 |
-
# ========== 配置图片路径 ==========
|
| 7 |
ENHANCE_INPUT_DIR = "sr_input"
|
| 8 |
ENHANCE_OUTPUT_DIR = "sr_output"
|
| 9 |
ENHANCE_IMG_NAMES = [f"img_{i}.jpg" for i in range(1, 30)]
|
|
@@ -121,6 +120,27 @@ def diagnose_demo(img_name):
|
|
| 121 |
return result_table, result_text, suggestion
|
| 122 |
|
| 123 |
css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
.orange-btn {
|
| 125 |
background: #FF7F1F !important;
|
| 126 |
color: white !important;
|
|
@@ -144,21 +164,24 @@ css = """
|
|
| 144 |
.button-row {
|
| 145 |
margin-top: 8px;
|
| 146 |
}
|
| 147 |
-
.
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
margin-bottom: 18px !important;
|
| 154 |
-
box-shadow: 0 3px 12px 2px rgba(60,64,67,.14);
|
| 155 |
}
|
| 156 |
-
.
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
letter-spacing: 1px;
|
| 163 |
}
|
| 164 |
.gr-image, .gr-image-preview {
|
|
@@ -181,9 +204,9 @@ def reset_seg():
|
|
| 181 |
def reset_diag():
|
| 182 |
return "请选择样例图片或者上传", None, [], "", ""
|
| 183 |
|
| 184 |
-
with gr.Blocks(title="
|
| 185 |
gr.HTML(f"<style>{css}</style>")
|
| 186 |
-
gr.
|
| 187 |
|
| 188 |
# 第一行:增强&分割(大框包裹)
|
| 189 |
with gr.Row():
|
|
@@ -193,8 +216,12 @@ with gr.Blocks(title="AI内窥镜影像辅助分析系统") as demo:
|
|
| 193 |
gr.HTML(f"<div class='big-title'>图像增强模块</div>")
|
| 194 |
enhance_select = gr.Dropdown(choices=ENHANCE_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
|
| 195 |
with gr.Row():
|
| 196 |
-
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
with gr.Row(elem_classes="button-row"):
|
| 199 |
enhance_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
|
| 200 |
enhance_btn = gr.Button("点击执行图片增强", elem_classes="orange-btn")
|
|
@@ -208,8 +235,12 @@ with gr.Blocks(title="AI内窥镜影像辅助分析系统") as demo:
|
|
| 208 |
gr.HTML(f"<div class='big-title'>图像分割模块</div>")
|
| 209 |
seg_select = gr.Dropdown(choices=SEG_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
|
| 210 |
with gr.Row():
|
| 211 |
-
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
with gr.Row(elem_classes="button-row"):
|
| 214 |
seg_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
|
| 215 |
seg_btn = gr.Button("点击执行分割", elem_classes="orange-btn")
|
|
@@ -225,7 +256,8 @@ with gr.Blocks(title="AI内窥镜影像辅助分析系统") as demo:
|
|
| 225 |
# 1. 输入图片+按钮
|
| 226 |
with gr.Column():
|
| 227 |
diag_select = gr.Dropdown(choices=DIAG_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
|
| 228 |
-
diag_input_img = gr.Image(
|
|
|
|
| 229 |
with gr.Row(elem_classes="button-row"):
|
| 230 |
diag_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
|
| 231 |
diag_btn = gr.Button("点击执行诊断", elem_classes="orange-btn")
|
|
|
|
| 3 |
import os
|
| 4 |
import random
|
| 5 |
|
|
|
|
| 6 |
ENHANCE_INPUT_DIR = "sr_input"
|
| 7 |
ENHANCE_OUTPUT_DIR = "sr_output"
|
| 8 |
ENHANCE_IMG_NAMES = [f"img_{i}.jpg" for i in range(1, 30)]
|
|
|
|
| 120 |
return result_table, result_text, suggestion
|
| 121 |
|
| 122 |
css = """
|
| 123 |
+
.project-title {
|
| 124 |
+
font-size: 38px; font-weight:bold; text-align:center; margin-bottom:40px;
|
| 125 |
+
letter-spacing:2px;
|
| 126 |
+
}
|
| 127 |
+
.big-group {
|
| 128 |
+
background: #F5F6F7 !important;
|
| 129 |
+
border: 2px dashed #123A7A !important;
|
| 130 |
+
border-radius: 18px !important;
|
| 131 |
+
padding: 28px 18px 24px 18px !important;
|
| 132 |
+
margin-top: 28px !important;
|
| 133 |
+
margin-bottom: 18px !important;
|
| 134 |
+
box-shadow: 0 3px 12px 2px rgba(60,64,67,.10);
|
| 135 |
+
}
|
| 136 |
+
.big-title {
|
| 137 |
+
font-size: 25px;
|
| 138 |
+
font-weight: bold;
|
| 139 |
+
margin-bottom: 18px;
|
| 140 |
+
color: #123A7A;
|
| 141 |
+
text-align:center;
|
| 142 |
+
letter-spacing: 1px;
|
| 143 |
+
}
|
| 144 |
.orange-btn {
|
| 145 |
background: #FF7F1F !important;
|
| 146 |
color: white !important;
|
|
|
|
| 164 |
.button-row {
|
| 165 |
margin-top: 8px;
|
| 166 |
}
|
| 167 |
+
.image-label-wrap {
|
| 168 |
+
width: 300px;
|
| 169 |
+
margin: 0 auto;
|
| 170 |
+
display: flex;
|
| 171 |
+
flex-direction: column;
|
| 172 |
+
align-items: center;
|
|
|
|
|
|
|
| 173 |
}
|
| 174 |
+
.custom-image-label {
|
| 175 |
+
background: #2bb7da;
|
| 176 |
+
color: #fff;
|
| 177 |
+
font-size: 16px;
|
| 178 |
+
width: 100%;
|
| 179 |
+
text-align: center;
|
| 180 |
+
border-radius: 0 0 9px 9px;
|
| 181 |
+
padding: 6px 0 4px 0;
|
| 182 |
+
margin-top: 0;
|
| 183 |
+
margin-bottom: 0;
|
| 184 |
+
font-weight: 500;
|
| 185 |
letter-spacing: 1px;
|
| 186 |
}
|
| 187 |
.gr-image, .gr-image-preview {
|
|
|
|
| 204 |
def reset_diag():
|
| 205 |
return "请选择样例图片或者上传", None, [], "", ""
|
| 206 |
|
| 207 |
+
with gr.Blocks(title="消化道疾病智能分析系统") as demo:
|
| 208 |
gr.HTML(f"<style>{css}</style>")
|
| 209 |
+
gr.HTML('<div class="project-title">消化道疾病智能分析系统</div>')
|
| 210 |
|
| 211 |
# 第一行:增强&分割(大框包裹)
|
| 212 |
with gr.Row():
|
|
|
|
| 216 |
gr.HTML(f"<div class='big-title'>图像增强模块</div>")
|
| 217 |
enhance_select = gr.Dropdown(choices=ENHANCE_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
|
| 218 |
with gr.Row():
|
| 219 |
+
with gr.Column():
|
| 220 |
+
enhance_input_img = gr.Image(interactive=False, width=300, height=300, show_label=False)
|
| 221 |
+
gr.HTML('<div class="custom-image-label">原始图片</div>', elem_id=None, elem_classes="image-label-wrap")
|
| 222 |
+
with gr.Column():
|
| 223 |
+
enhance_output_img = gr.Image(interactive=False, width=300, height=300, show_label=False)
|
| 224 |
+
gr.HTML('<div class="custom-image-label">增强结果图片</div>', elem_id=None, elem_classes="image-label-wrap")
|
| 225 |
with gr.Row(elem_classes="button-row"):
|
| 226 |
enhance_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
|
| 227 |
enhance_btn = gr.Button("点击执行图片增强", elem_classes="orange-btn")
|
|
|
|
| 235 |
gr.HTML(f"<div class='big-title'>图像分割模块</div>")
|
| 236 |
seg_select = gr.Dropdown(choices=SEG_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
|
| 237 |
with gr.Row():
|
| 238 |
+
with gr.Column():
|
| 239 |
+
seg_input_img = gr.Image(interactive=False, width=300, height=300, show_label=False)
|
| 240 |
+
gr.HTML('<div class="custom-image-label">输入图片</div>', elem_id=None, elem_classes="image-label-wrap")
|
| 241 |
+
with gr.Column():
|
| 242 |
+
seg_output_img = gr.Image(interactive=False, width=300, height=300, show_label=False)
|
| 243 |
+
gr.HTML('<div class="custom-image-label">分割结果图片</div>', elem_id=None, elem_classes="image-label-wrap")
|
| 244 |
with gr.Row(elem_classes="button-row"):
|
| 245 |
seg_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
|
| 246 |
seg_btn = gr.Button("点击执行分割", elem_classes="orange-btn")
|
|
|
|
| 256 |
# 1. 输入图片+按钮
|
| 257 |
with gr.Column():
|
| 258 |
diag_select = gr.Dropdown(choices=DIAG_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
|
| 259 |
+
diag_input_img = gr.Image(interactive=False, width=300, height=300, show_label=False)
|
| 260 |
+
gr.HTML('<div class="custom-image-label">输入图片</div>', elem_id=None, elem_classes="image-label-wrap")
|
| 261 |
with gr.Row(elem_classes="button-row"):
|
| 262 |
diag_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
|
| 263 |
diag_btn = gr.Button("点击执行诊断", elem_classes="orange-btn")
|