UI: more compact layout
Browse files
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("
|
| 241 |
|
| 242 |
with gr.Row():
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 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 |
-
|
| 269 |
-
|
| 270 |
-
visual_output = gr.Label(num_top_classes=5, label="ResNet50")
|
| 271 |
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
|
|
|
| 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(
|