Rachel Ding commited on
Commit
b44206b
·
1 Parent(s): a94b543

NN view: one per row with prompt, top to bottom

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -14,16 +14,18 @@ TOP1_ID = SAMPLE_IDS[0] if SAMPLE_IDS else None
14
 
15
 
16
  def build_nn_view(sample_id: str | None):
17
- """NN view: NN1-NN10 from baseline (in prompt order). Each has spec + m_wav."""
18
  if not sample_id:
19
- return (None,) * (10 * 2)
20
  data = get_nn_demo_paths(sample_id, top_k=10)
21
  out = []
22
- for nn in data.get("nn_list", [])[:10]:
 
 
23
  out.extend([nn.get("spec"), nn.get("m_wav")])
24
- while len(out) < 20:
25
  out.append(None)
26
- return tuple(out[:20])
27
 
28
 
29
  def build_results_view(sample_id: str | None):
@@ -61,16 +63,17 @@ with gr.Blocks(title="NearestNeighbor Audio Demo", css=".gradio-container { max-
61
  **Audio labels**: **BG** = background noise | **FG** = generated foreground | **Mix** = BG + FG
62
  """)
63
 
64
- # ---- NN View: NN1-NN10 from baseline (in prompt order) ----
65
  with gr.Column(visible=True) as nn_col:
66
  gr.Markdown("### Nearest Neighbor: Baseline outputs (top 10 prompts)")
67
- nn_items = []
68
- with gr.Row():
69
- for i in range(10):
70
- with gr.Column(min_width=120):
71
- nn_items.append(gr.Image(label=f"NN{i+1}", show_label=True, height=140))
72
- nn_items.append(gr.Audio(label="Mix", show_label=True))
73
- nn_outputs = nn_items
 
74
 
75
  # ---- Results View: 3 prompts × 4 methods ----
76
  with gr.Column(visible=False) as res_col:
 
14
 
15
 
16
  def build_nn_view(sample_id: str | None):
17
+ """NN view: NN1-NN10 from baseline (in prompt order). Each row: prompt + spec + m_wav."""
18
  if not sample_id:
19
+ return (None,) * (10 + 10 * 2)
20
  data = get_nn_demo_paths(sample_id, top_k=10)
21
  out = []
22
+ for i, nn in enumerate(data.get("nn_list", [])[:10]):
23
+ prompt = nn.get("prompt", "") or ""
24
+ out.append(f"**NN{i+1}:** {prompt}" if prompt else "")
25
  out.extend([nn.get("spec"), nn.get("m_wav")])
26
+ while len(out) < 30:
27
  out.append(None)
28
+ return tuple(out[:30])
29
 
30
 
31
  def build_results_view(sample_id: str | None):
 
63
  **Audio labels**: **BG** = background noise | **FG** = generated foreground | **Mix** = BG + FG
64
  """)
65
 
66
+ # ---- NN View: NN1-NN10 from baseline, one per row with prompt ----
67
  with gr.Column(visible=True) as nn_col:
68
  gr.Markdown("### Nearest Neighbor: Baseline outputs (top 10 prompts)")
69
+ nn_outputs = []
70
+ for i in range(10):
71
+ with gr.Row():
72
+ nn_p_md = gr.Markdown(value="")
73
+ nn_outputs.append(nn_p_md)
74
+ nn_img = gr.Image(label=f"NN{i+1}", show_label=True, height=160)
75
+ nn_m = gr.Audio(label="Mix", show_label=True)
76
+ nn_outputs.extend([nn_img, nn_m])
77
 
78
  # ---- Results View: 3 prompts × 4 methods ----
79
  with gr.Column(visible=False) as res_col: