Tolulope Ogunremi commited on
Commit
799e05f
·
1 Parent(s): 430935f

last try gradio group

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -1018,12 +1018,13 @@ def create_integrated_gradio_interface(analyzer: MultiModelAnalyzer):
1018
 
1019
  return demo
1020
 
 
1021
  def create_root_interface(output_dir):
1022
  subdirs = get_top_level_dirs(output_dir)
1023
 
1024
  # Pre-load all analyzers
1025
  analyzers = {d.name: load_analyzer_for_subdir(d) for d in subdirs}
1026
- columns = {}
1027
 
1028
  with gr.Blocks() as demo:
1029
  gr.Markdown("## Select Analysis Directory")
@@ -1034,26 +1035,21 @@ def create_root_interface(output_dir):
1034
  label="Model Group"
1035
  )
1036
 
1037
- # Create all interfaces upfront
1038
  for idx, (name, analyzer) in enumerate(analyzers.items()):
1039
- with gr.Column(visible=(idx == 0), render=True) as col:
1040
  create_integrated_gradio_interface(analyzer)
1041
- columns[name] = col
1042
 
1043
  def switch_view(selected):
1044
- """Return visibility updates for each column"""
1045
- updates = []
1046
- for name in columns.keys():
1047
- is_visible = (name == selected)
1048
- print(f"Setting {name} visible={is_visible}") # DEBUG
1049
- updates.append(gr.update(visible=is_visible))
1050
- return updates
1051
 
1052
  # Connect the dropdown change event
1053
  subdir_dropdown.change(
1054
  fn=switch_view,
1055
  inputs=[subdir_dropdown],
1056
- outputs=list(columns.values())
1057
  )
1058
 
1059
  return demo
 
1018
 
1019
  return demo
1020
 
1021
+
1022
  def create_root_interface(output_dir):
1023
  subdirs = get_top_level_dirs(output_dir)
1024
 
1025
  # Pre-load all analyzers
1026
  analyzers = {d.name: load_analyzer_for_subdir(d) for d in subdirs}
1027
+ groups = {}
1028
 
1029
  with gr.Blocks() as demo:
1030
  gr.Markdown("## Select Analysis Directory")
 
1035
  label="Model Group"
1036
  )
1037
 
1038
+ # Create all interfaces upfront using Group instead of Column
1039
  for idx, (name, analyzer) in enumerate(analyzers.items()):
1040
+ with gr.Group(visible=(idx == 0)) as grp:
1041
  create_integrated_gradio_interface(analyzer)
1042
+ groups[name] = grp
1043
 
1044
  def switch_view(selected):
1045
+ """Return visibility updates for each group"""
1046
+ return [gr.update(visible=(name == selected)) for name in groups.keys()]
 
 
 
 
 
1047
 
1048
  # Connect the dropdown change event
1049
  subdir_dropdown.change(
1050
  fn=switch_view,
1051
  inputs=[subdir_dropdown],
1052
+ outputs=list(groups.values())
1053
  )
1054
 
1055
  return demo