Spaces:
Sleeping
Sleeping
| 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() | |