Converted button to event listeners.
Browse files
app.py
CHANGED
@@ -80,13 +80,27 @@ with gr.Blocks() as demo:
|
|
80 |
n_components = gr.Slider(1, 10, 4, step=1, label="Number of blobs")
|
81 |
clst_std = gr.Slider(.1, 1, .6, label="Blob Standard Deviation")
|
82 |
|
83 |
-
btn = gr.Button(label="Run")
|
84 |
|
85 |
with gr.Row():
|
86 |
graph_points = gr.Plot(label="K-Means++ Initial Points")
|
87 |
init_plus_one = gr.Plot(label="K-Means after one Step")
|
88 |
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
fn=k_means,
|
91 |
inputs=[n_samples, n_components, clst_std, n_clusters],
|
92 |
outputs=[graph_points, init_plus_one]
|
|
|
80 |
n_components = gr.Slider(1, 10, 4, step=1, label="Number of blobs")
|
81 |
clst_std = gr.Slider(.1, 1, .6, label="Blob Standard Deviation")
|
82 |
|
|
|
83 |
|
84 |
with gr.Row():
|
85 |
graph_points = gr.Plot(label="K-Means++ Initial Points")
|
86 |
init_plus_one = gr.Plot(label="K-Means after one Step")
|
87 |
|
88 |
+
n_samples.change(
|
89 |
+
fn=k_means,
|
90 |
+
inputs=[n_samples, n_components, clst_std, n_clusters],
|
91 |
+
outputs=[graph_points, init_plus_one]
|
92 |
+
)
|
93 |
+
n_clusters.change(
|
94 |
+
fn=k_means,
|
95 |
+
inputs=[n_samples, n_components, clst_std, n_clusters],
|
96 |
+
outputs=[graph_points, init_plus_one]
|
97 |
+
)
|
98 |
+
n_components.change(
|
99 |
+
fn=k_means,
|
100 |
+
inputs=[n_samples, n_components, clst_std, n_clusters],
|
101 |
+
outputs=[graph_points, init_plus_one]
|
102 |
+
)
|
103 |
+
clst_std.change(
|
104 |
fn=k_means,
|
105 |
inputs=[n_samples, n_components, clst_std, n_clusters],
|
106 |
outputs=[graph_points, init_plus_one]
|