zxcvb6958 commited on
Commit
1983a93
·
1 Parent(s): e76b204

update UI

Browse files
Files changed (1) hide show
  1. app.py +28 -26
app.py CHANGED
@@ -42,17 +42,17 @@ SUGGESTION_DICT = {
42
 
43
  def open_img(img_path):
44
  if not os.path.exists(img_path):
45
- img = Image.new("RGB", (400, 400), (200, 200, 200))
46
  else:
47
  img = Image.open(img_path)
48
  w, h = img.size
49
- if max(w, h) != 400:
50
  if w >= h:
51
- new_w = 400
52
- new_h = int(h * 400 / w)
53
  else:
54
- new_h = 400
55
- new_w = int(w * 400 / h)
56
  img = img.resize((new_w, new_h), Image.LANCZOS)
57
  return img
58
 
@@ -132,26 +132,28 @@ css = """
132
  background: #FF7F1F !important;
133
  color: white !important;
134
  font-weight: bold;
135
- border: none !important;
136
  border-radius: 12px !important;
137
  font-size: 16px !important;
138
  padding: 10px 18px !important;
139
  margin-left: 10px !important;
 
140
  }
141
  .gray-btn {
142
  background: #EBEBEE !important;
143
  color: black !important;
144
  font-weight: bold;
145
- border: none !important;
146
  border-radius: 12px !important;
147
  font-size: 16px !important;
148
  padding: 10px 18px !important;
149
  margin-right: 10px !important;
 
150
  }
151
  .button-row {
152
- margin-top: 16px;
153
  }
154
- .diagnosis-group {
155
  border: 2px solid #dadce0 !important;
156
  border-radius: 15px !important;
157
  padding: 28px 12px 24px 12px !important;
@@ -160,7 +162,7 @@ css = """
160
  background: #FAFAFA !important;
161
  box-shadow: 0 2px 6px 0 rgba(60,64,67,.11),0 1.5px 5px 0 rgba(60,64,67,.11);
162
  }
163
- .diagnosis-title {
164
  font-size: 22px;
165
  font-weight: bold;
166
  margin-bottom: 14px;
@@ -182,16 +184,16 @@ with gr.Blocks(title="AI内窥镜影像辅助分析系统") as demo:
182
  gr.HTML(f"<style>{css}</style>")
183
  gr.Markdown("<span style='font-size: 32px; font-weight: bold;'>AI内窥镜影像辅助分析系统</span>")
184
 
185
- # 第一行:增强&分割
186
  with gr.Row():
187
- # 增强
188
  with gr.Column():
189
- with gr.Group():
190
- gr.Markdown("<span style='font-size: 22px; font-weight: bold;'>图像增强模块</span>")
191
  enhance_select = gr.Dropdown(choices=ENHANCE_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
192
  with gr.Row():
193
- enhance_input_img = gr.Image(label="原始图片", interactive=False)
194
- enhance_output_img = gr.Image(label="增强结果图片", interactive=False)
195
  with gr.Row(elem_classes="button-row"):
196
  enhance_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
197
  enhance_btn = gr.Button("点击执行图片增强", elem_classes="orange-btn")
@@ -199,14 +201,14 @@ with gr.Blocks(title="AI内窥镜影像辅助分析系统") as demo:
199
  enhance_btn.click(fn=enhance_demo, inputs=enhance_select, outputs=enhance_output_img)
200
  enhance_reset_btn.click(fn=reset_enhance, inputs=None, outputs=[enhance_select, enhance_input_img, enhance_output_img])
201
 
202
- # 分割
203
  with gr.Column():
204
- with gr.Group():
205
- gr.Markdown("<span style='font-size: 22px; font-weight: bold;'>图像分割模块</span>")
206
  seg_select = gr.Dropdown(choices=SEG_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
207
  with gr.Row():
208
- seg_input_img = gr.Image(label="输入图片", interactive=False)
209
- seg_output_img = gr.Image(label="分割结果图片", interactive=False)
210
  with gr.Row(elem_classes="button-row"):
211
  seg_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
212
  seg_btn = gr.Button("点击执行分割", elem_classes="orange-btn")
@@ -214,15 +216,15 @@ with gr.Blocks(title="AI内窥镜影像辅助分析系统") as demo:
214
  seg_btn.click(fn=segment_demo, inputs=seg_select, outputs=seg_output_img)
215
  seg_reset_btn.click(fn=reset_seg, inputs=None, outputs=[seg_select, seg_input_img, seg_output_img])
216
 
217
- # 第二行:疾病诊断,Group加
218
  with gr.Row():
219
- with gr.Group(elem_classes="diagnosis-group"):
220
- gr.HTML(f"<div class='diagnosis-title'>疾病分类模块</div>")
221
  with gr.Row():
222
  # 1. 输入图片+按钮
223
  with gr.Column():
224
  diag_select = gr.Dropdown(choices=DIAG_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
225
- diag_input_img = gr.Image(label="输入图片", interactive=False)
226
  with gr.Row(elem_classes="button-row"):
227
  diag_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
228
  diag_btn = gr.Button("点击执行诊断", elem_classes="orange-btn")
 
42
 
43
  def open_img(img_path):
44
  if not os.path.exists(img_path):
45
+ img = Image.new("RGB", (300, 300), (200, 200, 200))
46
  else:
47
  img = Image.open(img_path)
48
  w, h = img.size
49
+ if max(w, h) != 300:
50
  if w >= h:
51
+ new_w = 300
52
+ new_h = int(h * 300 / w)
53
  else:
54
+ new_h = 300
55
+ new_w = int(w * 300 / h)
56
  img = img.resize((new_w, new_h), Image.LANCZOS)
57
  return img
58
 
 
132
  background: #FF7F1F !important;
133
  color: white !important;
134
  font-weight: bold;
135
+ border: 2px solid #ff6100 !important;
136
  border-radius: 12px !important;
137
  font-size: 16px !important;
138
  padding: 10px 18px !important;
139
  margin-left: 10px !important;
140
+ box-shadow: none !important;
141
  }
142
  .gray-btn {
143
  background: #EBEBEE !important;
144
  color: black !important;
145
  font-weight: bold;
146
+ border: 2px solid #bfbfbf !important;
147
  border-radius: 12px !important;
148
  font-size: 16px !important;
149
  padding: 10px 18px !important;
150
  margin-right: 10px !important;
151
+ box-shadow: none !important;
152
  }
153
  .button-row {
154
+ margin-top: 4px;
155
  }
156
+ .big-group {
157
  border: 2px solid #dadce0 !important;
158
  border-radius: 15px !important;
159
  padding: 28px 12px 24px 12px !important;
 
162
  background: #FAFAFA !important;
163
  box-shadow: 0 2px 6px 0 rgba(60,64,67,.11),0 1.5px 5px 0 rgba(60,64,67,.11);
164
  }
165
+ .big-title {
166
  font-size: 22px;
167
  font-weight: bold;
168
  margin-bottom: 14px;
 
184
  gr.HTML(f"<style>{css}</style>")
185
  gr.Markdown("<span style='font-size: 32px; font-weight: bold;'>AI内窥镜影像辅助分析系统</span>")
186
 
187
+ # 第一行:增强&分割(大框包裹)
188
  with gr.Row():
189
+ # 图像增强
190
  with gr.Column():
191
+ with gr.Group(elem_classes="big-group"):
192
+ gr.HTML(f"<div class='big-title'>图像增强模块</div>")
193
  enhance_select = gr.Dropdown(choices=ENHANCE_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
194
  with gr.Row():
195
+ enhance_input_img = gr.Image(label="原始图片", interactive=False, width=300, height=300)
196
+ enhance_output_img = gr.Image(label="增强结果图片", interactive=False, width=300, height=300)
197
  with gr.Row(elem_classes="button-row"):
198
  enhance_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
199
  enhance_btn = gr.Button("点击执行图片增强", elem_classes="orange-btn")
 
201
  enhance_btn.click(fn=enhance_demo, inputs=enhance_select, outputs=enhance_output_img)
202
  enhance_reset_btn.click(fn=reset_enhance, inputs=None, outputs=[enhance_select, enhance_input_img, enhance_output_img])
203
 
204
+ # 图像分割
205
  with gr.Column():
206
+ with gr.Group(elem_classes="big-group"):
207
+ gr.HTML(f"<div class='big-title'>图像分割模块</div>")
208
  seg_select = gr.Dropdown(choices=SEG_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
209
  with gr.Row():
210
+ seg_input_img = gr.Image(label="输入图片", interactive=False, width=300, height=300)
211
+ seg_output_img = gr.Image(label="分割结果图片", interactive=False, width=300, height=300)
212
  with gr.Row(elem_classes="button-row"):
213
  seg_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
214
  seg_btn = gr.Button("点击执行分割", elem_classes="orange-btn")
 
216
  seg_btn.click(fn=segment_demo, inputs=seg_select, outputs=seg_output_img)
217
  seg_reset_btn.click(fn=reset_seg, inputs=None, outputs=[seg_select, seg_input_img, seg_output_img])
218
 
219
+ # 第二行:疾病诊断大框包裹)
220
  with gr.Row():
221
+ with gr.Group(elem_classes="big-group"):
222
+ gr.HTML(f"<div class='big-title'>疾病分类模块</div>")
223
  with gr.Row():
224
  # 1. 输入图片+按钮
225
  with gr.Column():
226
  diag_select = gr.Dropdown(choices=DIAG_CHOICES, value="请选择样例图片或者上传", label="选择样例图片", filterable=True)
227
+ diag_input_img = gr.Image(label="输入图片", interactive=False, width=300, height=300)
228
  with gr.Row(elem_classes="button-row"):
229
  diag_reset_btn = gr.Button("Reset", elem_classes="gray-btn")
230
  diag_btn = gr.Button("点击执行诊断", elem_classes="orange-btn")