File size: 808 Bytes
c3392d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import importlib
import gradio as gr
import os
import sys
import copy
import pathlib

os.environ["SYSTEM"] = "pretend-not-spaces"

demo_dir = pathlib.Path(__file__).parent / "demos"


all_demos = []
for p in os.listdir("./demos"):
    all_demos.append(p)

demo_module = None
with gr.Blocks() as mega_demo:
    with gr.Tabs():
        for demo_name in all_demos:
            with gr.TabItem(demo_name):
                old_path = copy.deepcopy(sys.path)
                sys.path = [os.path.join(demo_dir, demo_name)] + sys.path
                if demo_module is None:
                    demo_module = importlib.import_module(f"run")
                else:
                    demo_module = importlib.reload(demo_module)
                demo_module.demo
                sys.path = old_path

mega_demo.launch()