Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
import matplotlib.pyplot as plt
|
|
|
4 |
import seaborn as sns
|
5 |
import plotly.express as px
|
6 |
import json
|
@@ -135,14 +136,13 @@ def plot_scatter_tab5(cat, x, y, z, col):
|
|
135 |
|
136 |
|
137 |
# Tab 6
|
138 |
-
|
139 |
-
|
140 |
-
#
|
141 |
-
|
142 |
-
|
143 |
|
144 |
-
|
145 |
-
|
146 |
|
147 |
# Gradio Interface
|
148 |
with gr.Blocks() as demo:
|
@@ -229,15 +229,15 @@ with gr.Blocks() as demo:
|
|
229 |
],
|
230 |
gr.Plot(label="plot", format="png",), allow_flagging="never",
|
231 |
)
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
|
237 |
-
|
238 |
-
|
239 |
|
240 |
-
|
241 |
|
242 |
|
243 |
# Launch the Gradio app
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
import matplotlib.pyplot as plt
|
4 |
+
import numpy as np
|
5 |
import seaborn as sns
|
6 |
import plotly.express as px
|
7 |
import json
|
|
|
136 |
|
137 |
|
138 |
# Tab 6
|
139 |
+
data_with_text = pd.read_csv("./tagged_data_with_text.csv")
|
140 |
+
def random_sample(r: gr.Request):
|
141 |
+
# sample a random row
|
142 |
+
sample = data_with_text.sample(1).to_dict(orient="records")[0]
|
|
|
143 |
|
144 |
+
markdown_text = '\n\n'.join([f"Category : {sample['Category']}:{sample['Sub-Category']}", f"Model : {sample['model']}", f"**Tag** : {sample['tag']}", f"**Prompt** : {sample['Prompt']}", f"**Answer** : {sample['answer']}"])
|
145 |
+
return markdown_text
|
146 |
|
147 |
# Gradio Interface
|
148 |
with gr.Blocks() as demo:
|
|
|
229 |
],
|
230 |
gr.Plot(label="plot", format="png",), allow_flagging="never",
|
231 |
)
|
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
|