Spaces:
Sleeping
Sleeping
Switch to Gradio version
Browse files
app.py
CHANGED
@@ -2,22 +2,32 @@ import gradio as gr
|
|
2 |
import matplotlib.pyplot as plt
|
3 |
import numpy as np
|
4 |
|
5 |
-
def plot_3d():
|
6 |
-
#
|
7 |
-
t = np.linspace(0,
|
8 |
x = np.sin(t)
|
9 |
y = np.cos(t)
|
10 |
z = t
|
11 |
|
|
|
12 |
fig = plt.figure()
|
13 |
-
ax = fig.add_subplot(111, projection=
|
14 |
ax.plot(x, y, z, label="3D Spiral")
|
15 |
ax.legend()
|
16 |
|
17 |
return fig
|
18 |
|
19 |
-
# Build Gradio interface
|
20 |
-
demo = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
if __name__ == "__main__":
|
23 |
demo.launch()
|
|
|
2 |
import matplotlib.pyplot as plt
|
3 |
import numpy as np
|
4 |
|
5 |
+
def plot_3d(max_t, num_points):
|
6 |
+
# Generate sequence
|
7 |
+
t = np.linspace(0, max_t, num_points)
|
8 |
x = np.sin(t)
|
9 |
y = np.cos(t)
|
10 |
z = t
|
11 |
|
12 |
+
# Plot
|
13 |
fig = plt.figure()
|
14 |
+
ax = fig.add_subplot(111, projection="3d")
|
15 |
ax.plot(x, y, z, label="3D Spiral")
|
16 |
ax.legend()
|
17 |
|
18 |
return fig
|
19 |
|
20 |
+
# Build Gradio interface with sliders
|
21 |
+
demo = gr.Interface(
|
22 |
+
fn=plot_3d,
|
23 |
+
inputs=[
|
24 |
+
gr.Slider(5, 50, value=20, step=1, label="Spiral Length"),
|
25 |
+
gr.Slider(100, 2000, value=500, step=50, label="Number of Points")
|
26 |
+
],
|
27 |
+
outputs="plot",
|
28 |
+
title="3D Hidden States Visualization",
|
29 |
+
description="Adjust the spiral length and number of points to explore the 3D curve."
|
30 |
+
)
|
31 |
|
32 |
if __name__ == "__main__":
|
33 |
demo.launch()
|