Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,14 +2,12 @@ import gradio as gr
|
|
2 |
import pandas as pd
|
3 |
import seaborn as sns
|
4 |
import matplotlib.pyplot as plt
|
5 |
-
|
6 |
-
# Load the Iris dataset
|
7 |
-
iris_df = sns.load_dataset('iris')
|
8 |
|
9 |
# Function to plot histogram
|
10 |
-
def plot_histogram(
|
11 |
# Read the CSV file
|
12 |
-
custom_df = pd.read_csv(
|
13 |
|
14 |
# Plot histogram
|
15 |
plt.figure(figsize=(8, 6))
|
@@ -20,9 +18,9 @@ def plot_histogram(csv_file, column):
|
|
20 |
return plt
|
21 |
|
22 |
# Function to plot scatter plot
|
23 |
-
def plot_scatter(
|
24 |
# Read the CSV file
|
25 |
-
custom_df = pd.read_csv(
|
26 |
|
27 |
# Plot scatter plot
|
28 |
plt.figure(figsize=(8, 6))
|
@@ -32,24 +30,24 @@ def plot_scatter(csv_file, x_axis, y_axis):
|
|
32 |
plt.ylabel(y_axis)
|
33 |
return plt
|
34 |
|
35 |
-
# Create the Gradio interface
|
36 |
-
|
37 |
fn=plot_histogram,
|
38 |
-
inputs=["
|
39 |
outputs="plot",
|
40 |
title="Histogram Plotter",
|
41 |
description="Upload a CSV file and select a column to plot its histogram."
|
42 |
)
|
43 |
|
44 |
-
#
|
45 |
-
|
46 |
fn=plot_scatter,
|
47 |
-
inputs=["
|
48 |
outputs="plot",
|
49 |
title="Scatter Plotter",
|
50 |
description="Upload a CSV file and select X and Y columns to plot a scatter plot."
|
51 |
)
|
52 |
|
53 |
# Launch the Gradio interfaces
|
54 |
-
|
55 |
-
|
|
|
2 |
import pandas as pd
|
3 |
import seaborn as sns
|
4 |
import matplotlib.pyplot as plt
|
5 |
+
from io import StringIO
|
|
|
|
|
6 |
|
7 |
# Function to plot histogram
|
8 |
+
def plot_histogram(file_contents, column):
|
9 |
# Read the CSV file
|
10 |
+
custom_df = pd.read_csv(StringIO(file_contents))
|
11 |
|
12 |
# Plot histogram
|
13 |
plt.figure(figsize=(8, 6))
|
|
|
18 |
return plt
|
19 |
|
20 |
# Function to plot scatter plot
|
21 |
+
def plot_scatter(file_contents, x_axis, y_axis):
|
22 |
# Read the CSV file
|
23 |
+
custom_df = pd.read_csv(StringIO(file_contents))
|
24 |
|
25 |
# Plot scatter plot
|
26 |
plt.figure(figsize=(8, 6))
|
|
|
30 |
plt.ylabel(y_axis)
|
31 |
return plt
|
32 |
|
33 |
+
# Create the Gradio interface for histogram
|
34 |
+
iface_histogram = gr.Interface(
|
35 |
fn=plot_histogram,
|
36 |
+
inputs=[gr.inputs.File(label="Upload CSV file"), "text"],
|
37 |
outputs="plot",
|
38 |
title="Histogram Plotter",
|
39 |
description="Upload a CSV file and select a column to plot its histogram."
|
40 |
)
|
41 |
|
42 |
+
# Create the Gradio interface for scatter plot
|
43 |
+
iface_scatter = gr.Interface(
|
44 |
fn=plot_scatter,
|
45 |
+
inputs=[gr.inputs.File(label="Upload CSV file"), "text", "text"],
|
46 |
outputs="plot",
|
47 |
title="Scatter Plotter",
|
48 |
description="Upload a CSV file and select X and Y columns to plot a scatter plot."
|
49 |
)
|
50 |
|
51 |
# Launch the Gradio interfaces
|
52 |
+
iface_histogram.launch(share=True)
|
53 |
+
iface_scatter.launch(share=True)
|