Fix Gradio 6.x compatibility: move css_paths to launch() method
Browse files- app.py +8 -2
- ui/interface.py +4 -8
app.py
CHANGED
|
@@ -137,7 +137,7 @@ except Exception as e:
|
|
| 137 |
|
| 138 |
# Create the Gradio interface
|
| 139 |
log_timing("Creating Gradio interface")
|
| 140 |
-
demo = create_interface()
|
| 141 |
log_timing("Gradio interface created")
|
| 142 |
|
| 143 |
# Launch app
|
|
@@ -148,4 +148,10 @@ if __name__ == "__main__":
|
|
| 148 |
print(f"{'='*70}\n")
|
| 149 |
print("Starting Gradio app...")
|
| 150 |
log_timing("Launching Gradio server")
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
# Create the Gradio interface
|
| 139 |
log_timing("Creating Gradio interface")
|
| 140 |
+
demo, css_path = create_interface()
|
| 141 |
log_timing("Gradio interface created")
|
| 142 |
|
| 143 |
# Launch app
|
|
|
|
| 148 |
print(f"{'='*70}\n")
|
| 149 |
print("Starting Gradio app...")
|
| 150 |
log_timing("Launching Gradio server")
|
| 151 |
+
|
| 152 |
+
# Gradio 6.x: CSS goes in launch() not Blocks()
|
| 153 |
+
launch_kwargs = {"server_name": "0.0.0.0", "server_port": 7860}
|
| 154 |
+
if css_path.exists():
|
| 155 |
+
launch_kwargs["css_paths"] = [css_path]
|
| 156 |
+
|
| 157 |
+
demo.launch(**launch_kwargs)
|
ui/interface.py
CHANGED
|
@@ -17,13 +17,7 @@ def create_interface():
|
|
| 17 |
"""Create and return the Gradio interface"""
|
| 18 |
interface_start = time.time()
|
| 19 |
|
| 20 |
-
|
| 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("""
|
| 28 |
<div class="main-header">
|
| 29 |
<h1>🎤 Caribbean Voices Hackathon</h1>
|
|
@@ -284,5 +278,7 @@ def create_interface():
|
|
| 284 |
timestamp = datetime.now().strftime("%H:%M:%S.%f")[:-3]
|
| 285 |
print(f"[{timestamp}] ⏱️ Total interface creation: {interface_time:.3f}s")
|
| 286 |
|
| 287 |
-
|
|
|
|
|
|
|
| 288 |
|
|
|
|
| 17 |
"""Create and return the Gradio interface"""
|
| 18 |
interface_start = time.time()
|
| 19 |
|
| 20 |
+
with gr.Blocks(title="Caribbean Voices - OWSM Platform") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
gr.Markdown("""
|
| 22 |
<div class="main-header">
|
| 23 |
<h1>🎤 Caribbean Voices Hackathon</h1>
|
|
|
|
| 278 |
timestamp = datetime.now().strftime("%H:%M:%S.%f")[:-3]
|
| 279 |
print(f"[{timestamp}] ⏱️ Total interface creation: {interface_time:.3f}s")
|
| 280 |
|
| 281 |
+
# Return demo and CSS path for Gradio 6.x (CSS goes in launch())
|
| 282 |
+
css_path = Path(__file__).parent / "styles.css"
|
| 283 |
+
return demo, css_path
|
| 284 |
|