Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.express as px
|
4 |
+
|
5 |
+
# Create a function to write the CSV file
|
6 |
+
def write_csv(record_count, topic, intervention):
|
7 |
+
df = pd.DataFrame({
|
8 |
+
"RecordCount": [record_count],
|
9 |
+
"Topic": [topic],
|
10 |
+
"Intervention": [intervention]
|
11 |
+
})
|
12 |
+
df.to_csv("records.csv", index=False, mode='a')
|
13 |
+
|
14 |
+
# Create a function to plot the data from the CSV file
|
15 |
+
def plot_data():
|
16 |
+
df = pd.read_csv("records.csv")
|
17 |
+
fig = px.scatter(df, x="RecordCount", y="Intervention", color="Topic")
|
18 |
+
return fig
|
19 |
+
|
20 |
+
# Define the inputs for the Gradio interface
|
21 |
+
inputs = [
|
22 |
+
gr.inputs.Slider(label="Record Count", min=0, max=100, default=50),
|
23 |
+
gr.inputs.Textbox(label="Topic"),
|
24 |
+
gr.inputs.Textbox(label="Intervention")
|
25 |
+
]
|
26 |
+
|
27 |
+
# Define the outputs for the Gradio interface
|
28 |
+
outputs = [
|
29 |
+
gr.outputs.Plotly(plot_data),
|
30 |
+
gr.outputs.Textbox(label="Data written to records.csv")
|
31 |
+
]
|
32 |
+
|
33 |
+
# Create the Gradio interface
|
34 |
+
interface = gr.Interface(write_csv, inputs, outputs, title="Record Plotter")
|
35 |
+
|
36 |
+
# Launch the Gradio interface
|
37 |
+
interface.launch()
|