Spaces:
Running on Zero
Running on Zero
File size: 1,262 Bytes
e8c5cc2 | 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 34 35 36 37 38 39 40 41 42 43 44 45 46 | """Run the Gradio UI. The API must already be running.
python scripts/serve_api.py --config configs/app.yaml (terminal 1)
python scripts/serve_ui.py --config configs/app.yaml (terminal 2)
"""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from src.config import load_config
from src.ui.app import build_demo
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--config", default="configs/app.yaml")
parser.add_argument("--api", default=None, help="Base URL of the running FastAPI app")
parser.add_argument("--port", type=int, default=None)
parser.add_argument("--share", action="store_true")
args = parser.parse_args()
cfg = load_config(args.config)
host = cfg["server"]["host"]
api_url = args.api or f"http://{host}:{cfg['server']['api_port']}"
print(f"[ui] talking to API at {api_url}")
import gradio as gr
demo = build_demo(api_url)
demo.launch(
server_name=host,
server_port=args.port or cfg["server"]["ui_port"],
share=args.share,
theme=gr.themes.Soft(),
)
if __name__ == "__main__":
main()
|