Spaces:
Running
Running
Commit
·
4dc666a
1
Parent(s):
9a0518c
Fix Gradio 6 css/js injection
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import time
|
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
MAX_DEMO_LEN = 20
|
|
|
|
| 10 |
|
| 11 |
ROSA_CODE = """
|
| 12 |
def rosa_qkv(qqq, kkk, vvv):
|
|
@@ -1450,7 +1451,12 @@ JS = """
|
|
| 1450 |
"""
|
| 1451 |
|
| 1452 |
|
| 1453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1454 |
gr.HTML(
|
| 1455 |
'<div class="page-header">'
|
| 1456 |
'<div class="page-title">ROSA QKV Demo</div>'
|
|
@@ -1493,4 +1499,7 @@ with gr.Blocks(css=CSS, js=JS) as demo:
|
|
| 1493 |
|
| 1494 |
|
| 1495 |
if __name__ == "__main__":
|
| 1496 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
MAX_DEMO_LEN = 20
|
| 10 |
+
GRADIO_MAJOR = int((gr.__version__ or "0").split(".", maxsplit=1)[0])
|
| 11 |
|
| 12 |
ROSA_CODE = """
|
| 13 |
def rosa_qkv(qqq, kkk, vvv):
|
|
|
|
| 1451 |
"""
|
| 1452 |
|
| 1453 |
|
| 1454 |
+
if GRADIO_MAJOR >= 6:
|
| 1455 |
+
demo_context = gr.Blocks()
|
| 1456 |
+
else:
|
| 1457 |
+
demo_context = gr.Blocks(css=CSS, js=JS)
|
| 1458 |
+
|
| 1459 |
+
with demo_context as demo:
|
| 1460 |
gr.HTML(
|
| 1461 |
'<div class="page-header">'
|
| 1462 |
'<div class="page-title">ROSA QKV Demo</div>'
|
|
|
|
| 1499 |
|
| 1500 |
|
| 1501 |
if __name__ == "__main__":
|
| 1502 |
+
launch_kwargs = {}
|
| 1503 |
+
if GRADIO_MAJOR >= 6:
|
| 1504 |
+
launch_kwargs = {"css": CSS, "js": JS, "ssr_mode": False}
|
| 1505 |
+
demo.launch(**launch_kwargs)
|