Fix Gradio CSS loading error: use css_paths parameter instead of css
Browse files- ui/interface.py +4 -18
ui/interface.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
"""Gradio UI interface for Caribbean Voices OWSM platform."""
|
| 2 |
import gradio as gr
|
| 3 |
-
import os
|
| 4 |
import time
|
| 5 |
from pathlib import Path
|
| 6 |
from datetime import datetime
|
|
@@ -14,28 +13,15 @@ from models.loader import get_available_models
|
|
| 14 |
from data.loader import load_data_from_hf_dataset
|
| 15 |
|
| 16 |
|
| 17 |
-
def load_css():
|
| 18 |
-
"""Load CSS from file and return as string"""
|
| 19 |
-
css_path = os.path.join(os.path.dirname(__file__), "styles.css")
|
| 20 |
-
if os.path.exists(css_path):
|
| 21 |
-
with open(css_path, 'r') as f:
|
| 22 |
-
return f.read()
|
| 23 |
-
return ""
|
| 24 |
-
|
| 25 |
-
|
| 26 |
def create_interface():
|
| 27 |
"""Create and return the Gradio interface"""
|
| 28 |
interface_start = time.time()
|
| 29 |
-
css_content = load_css()
|
| 30 |
-
css_time = time.time() - interface_start
|
| 31 |
-
timestamp = datetime.now().strftime("%H:%M:%S.%f")[:-3]
|
| 32 |
-
print(f"[{timestamp}] ⏱️ CSS loading: {css_time:.3f}s")
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
| 36 |
blocks_kwargs = {"title": "Caribbean Voices - OWSM Platform"}
|
| 37 |
-
if
|
| 38 |
-
blocks_kwargs["
|
| 39 |
|
| 40 |
with gr.Blocks(**blocks_kwargs) as demo:
|
| 41 |
gr.Markdown("""
|
|
|
|
| 1 |
"""Gradio UI interface for Caribbean Voices OWSM platform."""
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
import time
|
| 4 |
from pathlib import Path
|
| 5 |
from datetime import datetime
|
|
|
|
| 13 |
from data.loader import load_data_from_hf_dataset
|
| 14 |
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def create_interface():
|
| 17 |
"""Create and return the Gradio interface"""
|
| 18 |
interface_start = time.time()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
# Build CSS file path and configure Blocks
|
| 21 |
+
css_path = Path(__file__).parent / "styles.css"
|
| 22 |
blocks_kwargs = {"title": "Caribbean Voices - OWSM Platform"}
|
| 23 |
+
if css_path.exists():
|
| 24 |
+
blocks_kwargs["css_paths"] = [css_path]
|
| 25 |
|
| 26 |
with gr.Blocks(**blocks_kwargs) as demo:
|
| 27 |
gr.Markdown("""
|