Spaces:
Running
on
Zero
Running
on
Zero
Update ui_manager.py
Browse files- ui_manager.py +32 -26
ui_manager.py
CHANGED
|
@@ -243,24 +243,24 @@ class UIManager:
|
|
| 243 |
def create_interface(self):
|
| 244 |
"""Create professional user interface"""
|
| 245 |
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
# Gradio
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
if major_version >= 5:
|
| 259 |
-
# Gradio 5.x: use head parameter for CSS injection
|
| 260 |
-
blocks_kwargs["head"] = f"<style>{css}</style>"
|
| 261 |
else:
|
| 262 |
-
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
with gr.Blocks(**blocks_kwargs) as interface:
|
| 266 |
|
|
@@ -515,12 +515,18 @@ class UIManager:
|
|
| 515 |
"""Launch the UI interface"""
|
| 516 |
interface = self.create_interface()
|
| 517 |
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
def create_interface(self):
|
| 244 |
"""Create professional user interface"""
|
| 245 |
|
| 246 |
+
self._css = CSSStyles.get_main_css()
|
| 247 |
+
|
| 248 |
+
# Check Gradio version for API compatibility
|
| 249 |
+
self._gradio_version = gr.__version__
|
| 250 |
+
self._gradio_major = int(self._gradio_version.split('.')[0])
|
| 251 |
+
|
| 252 |
+
# Gradio 5.x: css/theme moved to launch(), Blocks() has minimal params
|
| 253 |
+
# Gradio 4.x: css/theme are in Blocks() constructor
|
| 254 |
+
if self._gradio_major >= 5:
|
| 255 |
+
blocks_kwargs = {
|
| 256 |
+
"title": "SceneWeaver - AI Background Generator"
|
| 257 |
+
}
|
|
|
|
|
|
|
|
|
|
| 258 |
else:
|
| 259 |
+
blocks_kwargs = {
|
| 260 |
+
"css": self._css,
|
| 261 |
+
"title": "SceneWeaver - AI Background Generator",
|
| 262 |
+
"theme": gr.themes.Soft()
|
| 263 |
+
}
|
| 264 |
|
| 265 |
with gr.Blocks(**blocks_kwargs) as interface:
|
| 266 |
|
|
|
|
| 515 |
"""Launch the UI interface"""
|
| 516 |
interface = self.create_interface()
|
| 517 |
|
| 518 |
+
# Build launch kwargs based on Gradio version
|
| 519 |
+
launch_kwargs = {
|
| 520 |
+
"share": share,
|
| 521 |
+
"debug": debug,
|
| 522 |
+
"show_error": True,
|
| 523 |
+
"quiet": False
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
# Gradio 5.x: css/theme are passed to launch()
|
| 527 |
+
# Gradio 4.x: these were already set in Blocks()
|
| 528 |
+
if self._gradio_major >= 5:
|
| 529 |
+
launch_kwargs["css"] = self._css
|
| 530 |
+
launch_kwargs["theme"] = gr.themes.Soft()
|
| 531 |
+
|
| 532 |
+
return interface.launch(**launch_kwargs)
|