an0nymous commited on
Commit
e2336a1
·
verified ·
1 Parent(s): f5e7b3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
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
- # eval_set=raw_data
139
- # def random_sample(r: gr.Request):
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
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
- # 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
 
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