Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -636,59 +636,51 @@ with gr.Blocks(css="""
|
|
| 636 |
""")
|
| 637 |
|
| 638 |
# Radio button for user choice: predefined data or upload dataset
|
| 639 |
-
choice_radio = gr.Radio(choices=["Use Default Dataset", "Upload Dataset"],
|
|
|
|
|
|
|
| 640 |
|
| 641 |
percentage_slider_los = gr.Slider(minimum=float(percentage_values_los[0]),
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
|
|
|
| 647 |
# File uploader for dataset (only visible if user chooses to upload a dataset)
|
| 648 |
file_input = gr.File(label="Upload HDF5 Dataset", file_types=[".h5"], visible=False)
|
|
|
|
| 649 |
# Dropdown for embedding type, also only visible when "Upload Dataset" is selected
|
| 650 |
emb_type = gr.Dropdown(choices=["Channel Embedding", "CLS Embedding"],
|
| 651 |
value="CLS Embedding",
|
| 652 |
label="Embedding Type",
|
| 653 |
visible=False)
|
|
|
|
| 654 |
# Confusion matrices display
|
| 655 |
with gr.Row():
|
| 656 |
raw_img_los = gr.Image(label="Raw Channels", type="pil", width=300, height=300)
|
| 657 |
embeddings_img_los = gr.Image(label="Embeddings", type="pil", width=300, height=300)
|
| 658 |
output_textbox = gr.Textbox(label="Console Output", lines=10, elem_id="console-output")
|
| 659 |
-
|
| 660 |
-
#emb_type = gr.Dropdown(choices=["Channel Embedding", "CLS Embedding"],
|
| 661 |
-
# value="CLS Embedding",
|
| 662 |
-
# label="Embedding Type", interactive=True)
|
| 663 |
-
|
| 664 |
-
# Update the file uploader visibility based on user choice
|
| 665 |
-
#def toggle_file_input(choice):
|
| 666 |
-
# return gr.update(visible=(choice == "Upload Dataset"))
|
| 667 |
|
| 668 |
-
#choice_radio.change(fn=toggle_file_input, inputs=[choice_radio], outputs=file_input)
|
| 669 |
-
|
| 670 |
# Update the visibility of file_input and emb_type based on user choice
|
| 671 |
def toggle_file_input_and_emb_type(choice):
|
| 672 |
visible = (choice == "Upload Dataset")
|
| 673 |
return gr.update(visible=visible), gr.update(visible=visible)
|
| 674 |
|
| 675 |
-
# Change visibility of file input and embedding type dropdown based on choice
|
| 676 |
choice_radio.change(fn=toggle_file_input_and_emb_type,
|
| 677 |
inputs=[choice_radio],
|
| 678 |
outputs=[file_input, emb_type])
|
| 679 |
-
|
| 680 |
# Layout for the UI
|
| 681 |
with gr.Row():
|
| 682 |
file_input.render() # File input will be hidden initially
|
| 683 |
emb_type.render() # Embedding type dropdown will be hidden initially
|
| 684 |
-
|
| 685 |
-
# When user makes a choice, update the display
|
| 686 |
-
#choice_radio.change(fn=handle_user_choice, inputs=[choice_radio, percentage_slider_los, file_input, emb_type],
|
| 687 |
-
# outputs=[raw_img_los, embeddings_img_los, output_textbox])
|
| 688 |
-
|
| 689 |
# When percentage slider changes (for predefined data)
|
| 690 |
-
percentage_slider_los.change(fn=handle_user_choice,
|
| 691 |
-
|
|
|
|
| 692 |
|
| 693 |
# When embedding type changes
|
| 694 |
#emb_type.change(fn=handle_user_choice, inputs=[choice_radio, percentage_slider_los, file_input, emb_type],
|
|
|
|
| 636 |
""")
|
| 637 |
|
| 638 |
# Radio button for user choice: predefined data or upload dataset
|
| 639 |
+
choice_radio = gr.Radio(choices=["Use Default Dataset", "Upload Dataset"],
|
| 640 |
+
label="Choose how to proceed",
|
| 641 |
+
value="Use Default Dataset")
|
| 642 |
|
| 643 |
percentage_slider_los = gr.Slider(minimum=float(percentage_values_los[0]),
|
| 644 |
+
maximum=float(percentage_values_los[-1]),
|
| 645 |
+
step=float((percentage_values_los[-1] - percentage_values_los[0]) / (len(percentage_values_los) - 1)),
|
| 646 |
+
value=float(percentage_values_los[0]),
|
| 647 |
+
label="Percentage of Data for Training",
|
| 648 |
+
interactive=True)
|
| 649 |
+
|
| 650 |
# File uploader for dataset (only visible if user chooses to upload a dataset)
|
| 651 |
file_input = gr.File(label="Upload HDF5 Dataset", file_types=[".h5"], visible=False)
|
| 652 |
+
|
| 653 |
# Dropdown for embedding type, also only visible when "Upload Dataset" is selected
|
| 654 |
emb_type = gr.Dropdown(choices=["Channel Embedding", "CLS Embedding"],
|
| 655 |
value="CLS Embedding",
|
| 656 |
label="Embedding Type",
|
| 657 |
visible=False)
|
| 658 |
+
|
| 659 |
# Confusion matrices display
|
| 660 |
with gr.Row():
|
| 661 |
raw_img_los = gr.Image(label="Raw Channels", type="pil", width=300, height=300)
|
| 662 |
embeddings_img_los = gr.Image(label="Embeddings", type="pil", width=300, height=300)
|
| 663 |
output_textbox = gr.Textbox(label="Console Output", lines=10, elem_id="console-output")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 664 |
|
|
|
|
|
|
|
| 665 |
# Update the visibility of file_input and emb_type based on user choice
|
| 666 |
def toggle_file_input_and_emb_type(choice):
|
| 667 |
visible = (choice == "Upload Dataset")
|
| 668 |
return gr.update(visible=visible), gr.update(visible=visible)
|
| 669 |
|
| 670 |
+
# Change visibility of file input and embedding type dropdown based on user choice
|
| 671 |
choice_radio.change(fn=toggle_file_input_and_emb_type,
|
| 672 |
inputs=[choice_radio],
|
| 673 |
outputs=[file_input, emb_type])
|
| 674 |
+
|
| 675 |
# Layout for the UI
|
| 676 |
with gr.Row():
|
| 677 |
file_input.render() # File input will be hidden initially
|
| 678 |
emb_type.render() # Embedding type dropdown will be hidden initially
|
| 679 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 680 |
# When percentage slider changes (for predefined data)
|
| 681 |
+
percentage_slider_los.change(fn=handle_user_choice,
|
| 682 |
+
inputs=[choice_radio, percentage_slider_los, file_input, emb_type],
|
| 683 |
+
outputs=[raw_img_los, embeddings_img_los, output_textbox])
|
| 684 |
|
| 685 |
# When embedding type changes
|
| 686 |
#emb_type.change(fn=handle_user_choice, inputs=[choice_radio, percentage_slider_los, file_input, emb_type],
|