Commit ·
5c5ab4f
1
Parent(s): 36a9b0a
Fix Gradio 6.0 API breakage on HF Spaces
Browse files- Image() no longer accepts show_download_button; remove it.
- theme/css moved off Blocks(...) to launch() in Gradio 6.0;
detect gr.__version__ and route accordingly so the file still
works under Gradio 4.x (local dev) and Gradio 6.x (HF Space).
app.py
CHANGED
|
@@ -564,7 +564,21 @@ HERO_HTML = """
|
|
| 564 |
</div>
|
| 565 |
"""
|
| 566 |
|
| 567 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 568 |
gr.HTML(HERO_HTML)
|
| 569 |
|
| 570 |
with gr.Row(equal_height=False):
|
|
@@ -643,8 +657,7 @@ with gr.Blocks(title="OneVision Encoder Codec View", theme=THEME, css=CUSTOM_CSS
|
|
| 643 |
with gr.Group(elem_classes="ovc-card"):
|
| 644 |
gr.Markdown("### Packed canvas")
|
| 645 |
canvas_out = gr.Image(
|
| 646 |
-
label="", show_label=False,
|
| 647 |
-
height=320,
|
| 648 |
)
|
| 649 |
with gr.Column(scale=1):
|
| 650 |
with gr.Group(elem_classes="ovc-card"):
|
|
@@ -674,4 +687,8 @@ with gr.Blocks(title="OneVision Encoder Codec View", theme=THEME, css=CUSTOM_CSS
|
|
| 674 |
|
| 675 |
|
| 676 |
if __name__ == "__main__":
|
| 677 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 564 |
</div>
|
| 565 |
"""
|
| 566 |
|
| 567 |
+
try:
|
| 568 |
+
_GR_MAJOR = int(gr.__version__.split(".")[0])
|
| 569 |
+
except Exception:
|
| 570 |
+
_GR_MAJOR = 4
|
| 571 |
+
_BLOCK_KW: dict = {"title": "OneVision Encoder Codec View"}
|
| 572 |
+
_LAUNCH_KW: dict = {}
|
| 573 |
+
if _GR_MAJOR >= 6:
|
| 574 |
+
# In Gradio 6.0 these moved off Blocks(...) onto launch(...).
|
| 575 |
+
_LAUNCH_KW["theme"] = THEME
|
| 576 |
+
_LAUNCH_KW["css"] = CUSTOM_CSS
|
| 577 |
+
else:
|
| 578 |
+
_BLOCK_KW["theme"] = THEME
|
| 579 |
+
_BLOCK_KW["css"] = CUSTOM_CSS
|
| 580 |
+
|
| 581 |
+
with gr.Blocks(**_BLOCK_KW) as demo:
|
| 582 |
gr.HTML(HERO_HTML)
|
| 583 |
|
| 584 |
with gr.Row(equal_height=False):
|
|
|
|
| 657 |
with gr.Group(elem_classes="ovc-card"):
|
| 658 |
gr.Markdown("### Packed canvas")
|
| 659 |
canvas_out = gr.Image(
|
| 660 |
+
label="", show_label=False, height=320,
|
|
|
|
| 661 |
)
|
| 662 |
with gr.Column(scale=1):
|
| 663 |
with gr.Group(elem_classes="ovc-card"):
|
|
|
|
| 687 |
|
| 688 |
|
| 689 |
if __name__ == "__main__":
|
| 690 |
+
demo.launch(
|
| 691 |
+
server_name="0.0.0.0",
|
| 692 |
+
server_port=int(os.environ.get("PORT", 7860)),
|
| 693 |
+
**_LAUNCH_KW,
|
| 694 |
+
)
|