Spaces:
Sleeping
Sleeping
OliverPerrin commited on
Commit ·
4423aaf
1
Parent(s): 79c54a8
Fix Gradio HF Space compatibility
Browse files- Add server_name='0.0.0.0' and server_port=7860 for Docker container
- Replace gr.JSON with gr.Textbox to avoid Gradio schema parsing bug
(additionalProperties: true causes TypeError in gradio_client)
- scripts/demo_gradio.py +18 -4
scripts/demo_gradio.py
CHANGED
|
@@ -554,7 +554,12 @@ def create_interface() -> gr.Blocks:
|
|
| 554 |
gr.Markdown("### Topic Confusion Matrix")
|
| 555 |
cm_output = gr.Image(value=cm_image, label="Confusion Matrix")
|
| 556 |
|
| 557 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 558 |
refresh_metrics = gr.Button("Refresh Metrics")
|
| 559 |
|
| 560 |
with gr.TabItem("Model Visuals"):
|
|
@@ -586,10 +591,14 @@ def create_interface() -> gr.Blocks:
|
|
| 586 |
inputs=None,
|
| 587 |
outputs=[visuals, visuals_notice],
|
| 588 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 589 |
refresh_metrics.click(
|
| 590 |
-
fn=
|
| 591 |
inputs=None,
|
| 592 |
-
outputs=[metrics_table, topic_table, cm_output,
|
| 593 |
)
|
| 594 |
return demo
|
| 595 |
|
|
@@ -601,7 +610,12 @@ app = demo
|
|
| 601 |
if __name__ == "__main__":
|
| 602 |
try:
|
| 603 |
get_pipeline()
|
| 604 |
-
demo.queue().launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 605 |
except Exception as exc: # pragma: no cover - surfaced in console
|
| 606 |
logger.error("Failed to launch demo: %s", exc, exc_info=True)
|
| 607 |
raise
|
|
|
|
| 554 |
gr.Markdown("### Topic Confusion Matrix")
|
| 555 |
cm_output = gr.Image(value=cm_image, label="Confusion Matrix")
|
| 556 |
|
| 557 |
+
metrics_meta_text = gr.Textbox(
|
| 558 |
+
value=json.dumps(metrics_meta, indent=2),
|
| 559 |
+
label="Metadata",
|
| 560 |
+
interactive=False,
|
| 561 |
+
lines=4,
|
| 562 |
+
)
|
| 563 |
refresh_metrics = gr.Button("Refresh Metrics")
|
| 564 |
|
| 565 |
with gr.TabItem("Model Visuals"):
|
|
|
|
| 591 |
inputs=None,
|
| 592 |
outputs=[visuals, visuals_notice],
|
| 593 |
)
|
| 594 |
+
def load_metrics_report_for_ui():
|
| 595 |
+
summary_df, topic_df, cm_image, metadata = load_metrics_report()
|
| 596 |
+
return summary_df, topic_df, cm_image, json.dumps(metadata, indent=2)
|
| 597 |
+
|
| 598 |
refresh_metrics.click(
|
| 599 |
+
fn=load_metrics_report_for_ui,
|
| 600 |
inputs=None,
|
| 601 |
+
outputs=[metrics_table, topic_table, cm_output, metrics_meta_text],
|
| 602 |
)
|
| 603 |
return demo
|
| 604 |
|
|
|
|
| 610 |
if __name__ == "__main__":
|
| 611 |
try:
|
| 612 |
get_pipeline()
|
| 613 |
+
demo.queue().launch(
|
| 614 |
+
server_name="0.0.0.0",
|
| 615 |
+
server_port=7860,
|
| 616 |
+
share=False,
|
| 617 |
+
allowed_paths=[str(OUTPUTS_DIR)],
|
| 618 |
+
)
|
| 619 |
except Exception as exc: # pragma: no cover - surfaced in console
|
| 620 |
logger.error("Failed to launch demo: %s", exc, exc_info=True)
|
| 621 |
raise
|