rexera commited on
Commit
0a7da3e
·
1 Parent(s): 4796948

UI: more compact layout

Browse files
Files changed (1) hide show
  1. app.py +36 -35
app.py CHANGED
@@ -235,47 +235,48 @@ def run_inference(sample_idx):
235
 
236
  # --- Gradio UI ---
237
 
238
- with gr.Blocks(title="MMRM Demo", theme=gr.themes.Soft()) as demo:
239
  gr.Markdown("# MMRM: Multimodal Multitask Restoring Model")
240
- gr.Markdown("Interactive demo comparing MMRM with baselines on real-world damaged characters.")
241
 
242
  with gr.Row():
243
- sample_dropdown = gr.Dropdown(
244
- choices=[x[1] for x in sample_options], # Use index as value
245
- type="value",
246
- label="Select Real-World Sample",
247
- info="Choose a sample from the real-world dataset."
248
- )
249
- sample_dropdown.choices = sample_options
250
-
251
- run_btn = gr.Button("Run Inference", variant="primary")
252
-
253
- gr.Markdown("### Input")
254
- with gr.Row():
255
- input_image = gr.Image(label="Damaged Character (Input)", type="pil", height=200, width=200)
256
- input_text = gr.Textbox(label="Context Info", lines=3)
257
-
258
- gr.Markdown("### Model Predictions")
259
- with gr.Row():
260
- with gr.Column():
261
- gr.Markdown("**Zero-shot (Pre-trained)**")
262
- zs_output = gr.Label(num_top_classes=5, label="GuwenBERT (Base)")
263
-
264
- with gr.Column():
265
- gr.Markdown("**Textual Baseline**")
266
- text_output = gr.Label(num_top_classes=5, label="RoBERTa (Finetuned)")
267
 
268
- with gr.Column():
269
- gr.Markdown("**Visual Baseline**")
270
- visual_output = gr.Label(num_top_classes=5, label="ResNet50")
271
 
272
- with gr.Column():
273
- gr.Markdown("**MMRM (Ours)**")
274
- mmrm_output = gr.Label(num_top_classes=5, label="Multimodal")
 
 
 
 
 
 
 
 
 
 
 
 
275
 
276
- gr.Markdown("### Intermediate Process: Visual Restoration")
277
- with gr.Row():
278
- restored_output = gr.Image(label="Restored Image (MMRM Output)", type="pil", height=200, width=200)
 
279
 
280
  # Event
281
  run_btn.click(
 
235
 
236
  # --- Gradio UI ---
237
 
238
+ with gr.Blocks(title="MMRM Demo", theme=gr.themes.Soft(spacing_size="sm", text_size="sm")) as demo:
239
  gr.Markdown("# MMRM: Multimodal Multitask Restoring Model")
240
+ gr.Markdown("Comparing MMRM with baselines on real-world damaged characters.")
241
 
242
  with gr.Row():
243
+ # --- Left Column: Inputs ---
244
+ with gr.Column(scale=1):
245
+ gr.Markdown("### Input Selection")
246
+ with gr.Row():
247
+ sample_dropdown = gr.Dropdown(
248
+ choices=[x[1] for x in sample_options], # Use index as value
249
+ type="value",
250
+ label="Select Sample",
251
+ container=False,
252
+ scale=3
253
+ )
254
+ sample_dropdown.choices = sample_options
255
+ run_btn = gr.Button("Run", variant="primary", scale=1, min_width=60)
 
 
 
 
 
 
 
 
 
 
 
256
 
257
+ with gr.Row():
258
+ input_image = gr.Image(label="Damaged Input", type="pil", height=250)
 
259
 
260
+ with gr.Row():
261
+ input_text = gr.Textbox(label="Context Info", lines=5)
262
+
263
+ # --- Right Column: Outputs ---
264
+ with gr.Column(scale=2):
265
+ gr.Markdown("### Model Predictions")
266
+ with gr.Row():
267
+ with gr.Column(min_width=80):
268
+ zs_output = gr.Label(num_top_classes=3, label="Zero-shot")
269
+ with gr.Column(min_width=80):
270
+ text_output = gr.Label(num_top_classes=3, label="Textual")
271
+ with gr.Column(min_width=80):
272
+ visual_output = gr.Label(num_top_classes=3, label="Visual")
273
+ with gr.Column(min_width=80):
274
+ mmrm_output = gr.Label(num_top_classes=3, label="MMRM")
275
 
276
+ with gr.Row():
277
+ with gr.Column():
278
+ gr.Markdown("### Visual Restoration")
279
+ restored_output = gr.Image(label="MMRM Output", type="pil", height=250)
280
 
281
  # Event
282
  run_btn.click(