Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -136,17 +136,10 @@ def plot_scatter_tab5(cat, x, y, z, col):
|
|
136 |
|
137 |
# Tab 6
|
138 |
eval_set=raw_data
|
139 |
-
def random_sample(
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
else: # filter by subsets (can be list)
|
144 |
-
if isinstance(subset, str):
|
145 |
-
subset = [subset]
|
146 |
-
# filter down dataset to only include the subset(s)
|
147 |
-
eval_set_filtered = eval_set.filter(lambda x: x["subset"] in subset)
|
148 |
-
sample_index = np.random.randint(0, len(eval_set_filtered) - 1)
|
149 |
-
sample = eval_set_filtered[sample_index]
|
150 |
|
151 |
markdown_text = '\n\n'.join([f"**{key}**:\n\n{value}" for key, value in sample.items()])
|
152 |
return markdown_text
|
@@ -239,13 +232,12 @@ with gr.Blocks() as demo:
|
|
239 |
with gr.TabItem("Dataset Viewer"):
|
240 |
with gr.Row():
|
241 |
# loads one sample
|
242 |
-
subset_selector = gr.Dropdown(sub_cats, label="Subset", value=None, multiselect=True)
|
243 |
button = gr.Button("Show Random Sample")
|
244 |
|
245 |
with gr.Row():
|
246 |
sample_display = gr.Markdown("{sampled data loads here}")
|
247 |
|
248 |
-
button.click(fn=random_sample,
|
249 |
|
250 |
|
251 |
# Launch the Gradio app
|
|
|
136 |
|
137 |
# Tab 6
|
138 |
eval_set=raw_data
|
139 |
+
def random_sample():
|
140 |
+
sample_index = np.random.randint(0, len(eval_set) - 1)
|
141 |
+
sample = eval_set[sample_index]
|
142 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
markdown_text = '\n\n'.join([f"**{key}**:\n\n{value}" for key, value in sample.items()])
|
145 |
return markdown_text
|
|
|
232 |
with gr.TabItem("Dataset Viewer"):
|
233 |
with gr.Row():
|
234 |
# loads one sample
|
|
|
235 |
button = gr.Button("Show Random Sample")
|
236 |
|
237 |
with gr.Row():
|
238 |
sample_display = gr.Markdown("{sampled data loads here}")
|
239 |
|
240 |
+
button.click(fn=random_sample, outputs=[sample_display])
|
241 |
|
242 |
|
243 |
# Launch the Gradio app
|