wi-lab commited on
Commit
254eeb2
·
verified ·
1 Parent(s): 2b9ed28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -6
app.py CHANGED
@@ -646,7 +646,11 @@ with gr.Blocks(css="""
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
-
 
 
 
 
650
  # Confusion matrices display
651
  with gr.Row():
652
  raw_img_los = gr.Image(label="Raw Channels", type="pil", width=300, height=300)
@@ -658,10 +662,20 @@ with gr.Blocks(css="""
658
  label="Embedding Type", interactive=True)
659
 
660
  # Update the file uploader visibility based on user choice
661
- def toggle_file_input(choice):
662
- return gr.update(visible=(choice == "Upload Dataset"))
 
 
 
 
 
 
 
663
 
664
- choice_radio.change(fn=toggle_file_input, inputs=[choice_radio], outputs=file_input)
 
 
 
665
 
666
  # When user makes a choice, update the display
667
  choice_radio.change(fn=handle_user_choice, inputs=[choice_radio, percentage_slider_los, file_input, emb_type],
@@ -672,8 +686,8 @@ with gr.Blocks(css="""
672
  outputs=[raw_img_los, embeddings_img_los, output_textbox])
673
 
674
  # When embedding type changes
675
- emb_type.change(fn=handle_user_choice, inputs=[choice_radio, percentage_slider_los, file_input, emb_type],
676
- outputs=[raw_img_los, embeddings_img_los, output_textbox])
677
 
678
  # Add a conclusion section at the bottom
679
  gr.Markdown("""
 
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)
 
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
  # When user makes a choice, update the display
681
  choice_radio.change(fn=handle_user_choice, inputs=[choice_radio, percentage_slider_los, file_input, emb_type],
 
686
  outputs=[raw_img_los, embeddings_img_los, output_textbox])
687
 
688
  # When embedding type changes
689
+ #emb_type.change(fn=handle_user_choice, inputs=[choice_radio, percentage_slider_los, file_input, emb_type],
690
+ # outputs=[raw_img_los, embeddings_img_los, output_textbox])
691
 
692
  # Add a conclusion section at the bottom
693
  gr.Markdown("""