LenixC commited on
Commit
7bf6b63
·
1 Parent(s): 3c6e069

Arranged Slider side-by-side, and changed to on change instead of on button press.

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -81,18 +81,23 @@ with gr.Blocks() as demo:
81
 
82
  This based on the example [here](https://scikit-learn.org/stable/auto_examples/neighbors/plot_nca_dim_reduction.html#sphx-glr-auto-examples-neighbors-plot-nca-dim-reduction-py)
83
  """)
84
- n_neighbors = gr.Slider(2, 10, 3, step=1, label="Number of Neighbors for KNN")
85
- random_state = gr.Slider(0, 100, 0, step=1, label="Random State")
86
- btn = gr.Button(label="Run")
87
  with gr.Row():
88
  pca_graph = gr.Plot(label="PCA")
89
  lda_graph = gr.Plot(label="LDA")
90
  nca_graph = gr.Plot(label="NCA")
91
- btn.click(
92
- fn=reduce_dimensions,
93
- inputs=[n_neighbors, random_state],
94
- outputs=[pca_graph, lda_graph, nca_graph]
95
- )
 
 
 
 
 
96
 
97
  if __name__ == '__main__':
98
  demo.launch()
 
81
 
82
  This based on the example [here](https://scikit-learn.org/stable/auto_examples/neighbors/plot_nca_dim_reduction.html#sphx-glr-auto-examples-neighbors-plot-nca-dim-reduction-py)
83
  """)
84
+ with gr.Row():
85
+ n_neighbors = gr.Slider(2, 10, 3, step=1, label="Number of Neighbors for KNN")
86
+ random_state = gr.Slider(0, 100, 0, step=1, label="Random State")
87
  with gr.Row():
88
  pca_graph = gr.Plot(label="PCA")
89
  lda_graph = gr.Plot(label="LDA")
90
  nca_graph = gr.Plot(label="NCA")
91
+ n_neighbors.change(
92
+ fn=reduce_dimensions,
93
+ inputs=[n_neighbors, random_state],
94
+ outputs=[pca_graph, lda_graph, nca_graph]
95
+ )
96
+ random_state.change(
97
+ fn=reduce_dimensions,
98
+ inputs=[n_neighbors, random_state],
99
+ outputs=[pca_graph, lda_graph, nca_graph]
100
+ )
101
 
102
  if __name__ == '__main__':
103
  demo.launch()