File size: 809 Bytes
29570bf
132e707
 
 
1b07353
 
 
29570bf
 
 
132e707
1b07353
29570bf
1b07353
29570bf
 
132e707
29570bf
132e707
1b07353
 
 
 
 
 
 
 
 
 
 
29570bf
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
import matplotlib.pyplot as plt
import numpy as np

def plot_3d(max_t, num_points):
    # Generate sequence
    t = np.linspace(0, max_t, num_points)
    x = np.sin(t)
    y = np.cos(t)
    z = t

    # Plot
    fig = plt.figure()
    ax = fig.add_subplot(111, projection="3d")
    ax.plot(x, y, z, label="3D Spiral")
    ax.legend()

    return fig

# Build Gradio interface with sliders
demo = gr.Interface(
    fn=plot_3d,
    inputs=[
        gr.Slider(5, 50, value=20, step=1, label="Spiral Length"),
        gr.Slider(100, 2000, value=500, step=50, label="Number of Points")
    ],
    outputs="plot",
    title="3D Hidden States Visualization",
    description="Adjust the spiral length and number of points to explore the 3D curve."
)

if __name__ == "__main__":
    demo.launch()