Tolulope Ogunremi commited on
Commit
797ef46
·
1 Parent(s): 11d1c92

adding folder options

Browse files
Files changed (1) hide show
  1. app.py +52 -6
app.py CHANGED
@@ -3,6 +3,8 @@ import os
3
  import sys
4
  import subprocess
5
  import importlib
 
 
6
 
7
  def install_private_package():
8
  """Install private package from GitHub using token"""
@@ -100,6 +102,15 @@ OUTPUT_DIR = snapshot_download("tolulope/speech-model-analysis", repo_type="dat
100
  # return f"Error: {str(e)}"
101
 
102
 
 
 
 
 
 
 
 
 
 
103
  def create_integrated_gradio_interface(analyzer: MultiModelAnalyzer):
104
  """
105
  Create comprehensive Gradio interface with model comparison.
@@ -1006,16 +1017,51 @@ def create_integrated_gradio_interface(analyzer: MultiModelAnalyzer):
1006
 
1007
  return demo
1008
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1009
  if __name__ == "__main__":
1010
- # Create analyzer
1011
- analyzer = MultiModelAnalyzer(OUTPUT_DIR)
1012
 
1013
- # Create and launch interface
1014
- demo = create_integrated_gradio_interface(analyzer)
 
1015
  demo.launch(
1016
  theme=gr.themes.Soft()
1017
  # server_port=args.port,
1018
  # share=True # Creates public link
1019
  )
1020
- # demo = create_interface()
1021
- # demo.launch()
 
 
 
3
  import sys
4
  import subprocess
5
  import importlib
6
+ from pathlib import Path
7
+
8
 
9
  def install_private_package():
10
  """Install private package from GitHub using token"""
 
102
  # return f"Error: {str(e)}"
103
 
104
 
105
+
106
+ def get_top_level_dirs(root):
107
+ root = Path(root)
108
+ return [d for d in root.iterdir() if d.is_dir()]
109
+
110
+ def load_analyzer_for_subdir(subdir_path):
111
+ return MultiModelAnalyzer(str(subdir_path))
112
+
113
+
114
  def create_integrated_gradio_interface(analyzer: MultiModelAnalyzer):
115
  """
116
  Create comprehensive Gradio interface with model comparison.
 
1017
 
1018
  return demo
1019
 
1020
+
1021
+
1022
+ def create_root_interface(output_dir):
1023
+ subdirs = get_top_level_dirs(output_dir)
1024
+
1025
+ with gr.Blocks() as demo:
1026
+ gr.Markdown("## Select Analysis Directory")
1027
+
1028
+ subdir_dropdown = gr.Dropdown(
1029
+ choices=[d.name for d in subdirs],
1030
+ value=subdirs[0].name,
1031
+ label="Model Group"
1032
+ )
1033
+
1034
+ # Placeholder for UI built from a dynamically-created analyzer
1035
+ ui_container = gr.Column()
1036
+
1037
+ def swap_analyzer(selected):
1038
+ # clear and rebuild analyzer UI
1039
+ subdir_path = Path(output_dir) / selected
1040
+ analyzer = load_analyzer_for_subdir(subdir_path)
1041
+ sub_ui = create_integrated_gradio_interface(analyzer)
1042
+ return gr.update(value=sub_ui)
1043
+
1044
+ subdir_dropdown.change(
1045
+ fn=swap_analyzer,
1046
+ inputs=subdir_dropdown,
1047
+ outputs=ui_container
1048
+ )
1049
+
1050
+ return demo
1051
+
1052
  if __name__ == "__main__":
1053
+ # # Create analyzer
1054
+ # analyzer = MultiModelAnalyzer(OUTPUT_DIR)
1055
 
1056
+ # # Create and launch interface
1057
+ # demo = create_integrated_gradio_interface(analyzer)
1058
+ demo = create_root_interface(OUTPUT_DIR)
1059
  demo.launch(
1060
  theme=gr.themes.Soft()
1061
  # server_port=args.port,
1062
  # share=True # Creates public link
1063
  )
1064
+ # # demo = create_interface()
1065
+ # # demo.launch()
1066
+
1067
+