rdave88 commited on
Commit
1b07353
·
1 Parent(s): 29570bf

Switch to Gradio version

Browse files
Files changed (1) hide show
  1. app.py +16 -6
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
- # Example: simple spiral
7
- t = np.linspace(0, 20, 500)
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='3d')
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(fn=plot_3d, inputs=None, outputs="plot")
 
 
 
 
 
 
 
 
 
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()