Spaces:
Sleeping
Sleeping
Tolulope Ogunremi
commited on
Commit
·
5f6ed69
1
Parent(s):
799e05f
loading selected dirs with tabs
Browse files- app.py +15 -27
- config.json +3 -0
app.py
CHANGED
|
@@ -1022,39 +1022,27 @@ def create_integrated_gradio_interface(analyzer: MultiModelAnalyzer):
|
|
| 1022 |
def create_root_interface(output_dir):
|
| 1023 |
subdirs = get_top_level_dirs(output_dir)
|
| 1024 |
|
| 1025 |
-
#
|
| 1026 |
-
|
| 1027 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1028 |
|
| 1029 |
with gr.Blocks() as demo:
|
| 1030 |
-
gr.Markdown("##
|
| 1031 |
|
| 1032 |
-
|
| 1033 |
-
|
| 1034 |
-
|
| 1035 |
-
|
| 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
|
| 1056 |
|
| 1057 |
-
|
| 1058 |
if __name__ == "__main__":
|
| 1059 |
# # Create analyzer
|
| 1060 |
# analyzer = MultiModelAnalyzer(OUTPUT_DIR)
|
|
|
|
| 1022 |
def create_root_interface(output_dir):
|
| 1023 |
subdirs = get_top_level_dirs(output_dir)
|
| 1024 |
|
| 1025 |
+
# Load config
|
| 1026 |
+
try:
|
| 1027 |
+
with open("config.json") as f:
|
| 1028 |
+
config = json.load(f)
|
| 1029 |
+
selected = config.get("selected_dirs", [])
|
| 1030 |
+
if selected:
|
| 1031 |
+
subdirs = [d for d in subdirs if d.name in selected]
|
| 1032 |
+
except FileNotFoundError:
|
| 1033 |
+
pass # Load all if no config
|
| 1034 |
|
| 1035 |
with gr.Blocks() as demo:
|
| 1036 |
+
gr.Markdown("## Discrete Token Phoneme Analysis")
|
| 1037 |
|
| 1038 |
+
with gr.Tabs():
|
| 1039 |
+
for subdir in subdirs:
|
| 1040 |
+
with gr.Tab(subdir.name):
|
| 1041 |
+
analyzer = load_analyzer_for_subdir(subdir)
|
| 1042 |
+
create_integrated_gradio_interface(analyzer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1043 |
|
| 1044 |
return demo
|
| 1045 |
|
|
|
|
| 1046 |
if __name__ == "__main__":
|
| 1047 |
# # Create analyzer
|
| 1048 |
# analyzer = MultiModelAnalyzer(OUTPUT_DIR)
|
config.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"selected_dirs": ["processed_data_hi_pa", "processed_data_test"]
|
| 3 |
+
}
|