Spaces:
Runtime error
Runtime error
File size: 797 Bytes
b7b84f7 |
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 33 |
import importlib
import gradio as gr
import os
import sys
import copy
import pathlib
# At least one demo fails when caching examples
# Temporary fix just to get the build to pass
os.environ["SYSTEM"] = "SPACES"
demo_dir = pathlib.Path(__file__).parent / "demos"
all_demos = []
demo_module = None
for p in os.listdir("./demos"):
old_path = copy.deepcopy(sys.path)
sys.path = [os.path.join(demo_dir, p)] + sys.path
if demo_module is None:
demo_module = importlib.import_module(f"run")
else:
demo_module = importlib.reload(demo_module)
all_demos.append((p, demo_module.demo))
with gr.Blocks() as mega_demo:
with gr.Tabs():
for demo_name, demo in all_demos:
with gr.TabItem(demo_name):
demo.render()
mega_demo.launch()
|