Spaces:
Running
Running
“Namhyun-Kim”
commited on
Commit
·
5043904
1
Parent(s):
12d9d45
Fix Gradio schema crash
Browse files- README.md +8 -8
- app.py +27 -2
- requirements.txt +2 -2
README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title: LWM (Large Wireless Model)
|
| 3 |
-
emoji: 🛰
|
| 4 |
-
colorFrom: indigo
|
| 5 |
-
colorTo: red
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: LWM (Large Wireless Model)
|
| 3 |
+
emoji: 🛰
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 5.14.0
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -13,6 +13,29 @@ import matplotlib.pyplot as plt
|
|
| 13 |
import pandas as pd
|
| 14 |
from sklearn.metrics import f1_score
|
| 15 |
import seaborn as sns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
#################### BEAM PREDICTION #########################}
|
| 18 |
def beam_prediction_task(data_percentage, task_complexity, theme='Dark'):
|
|
@@ -729,5 +752,7 @@ with gr.Blocks(css="""
|
|
| 729 |
|
| 730 |
# Launch the app
|
| 731 |
if __name__ == "__main__":
|
| 732 |
-
|
| 733 |
-
|
|
|
|
|
|
|
|
|
| 13 |
import pandas as pd
|
| 14 |
from sklearn.metrics import f1_score
|
| 15 |
import seaborn as sns
|
| 16 |
+
# Gradio API schema helper hotfix: handle bool JSON schema entries (e.g., additionalProperties=True)
|
| 17 |
+
# that otherwise break gradio_client.utils.json_schema_to_python_type in Spaces.
|
| 18 |
+
try:
|
| 19 |
+
import gradio_client.utils as _gc_utils
|
| 20 |
+
|
| 21 |
+
_orig_json_schema_to_python_type = _gc_utils._json_schema_to_python_type # type: ignore[attr-defined]
|
| 22 |
+
|
| 23 |
+
def _json_schema_to_python_type_safe(schema, defs=None): # type: ignore[override]
|
| 24 |
+
if isinstance(schema, bool):
|
| 25 |
+
return "Any" if schema else "Never"
|
| 26 |
+
return _orig_json_schema_to_python_type(schema, defs)
|
| 27 |
+
|
| 28 |
+
def _json_schema_to_python_type_top(schema): # type: ignore[override]
|
| 29 |
+
if isinstance(schema, bool):
|
| 30 |
+
return "Any" if schema else "Never"
|
| 31 |
+
defs = schema.get("$defs") if isinstance(schema, dict) else None
|
| 32 |
+
return _json_schema_to_python_type_safe(schema, defs)
|
| 33 |
+
|
| 34 |
+
_gc_utils._json_schema_to_python_type = _json_schema_to_python_type_safe # type: ignore[attr-defined]
|
| 35 |
+
_gc_utils.json_schema_to_python_type = _json_schema_to_python_type_top # type: ignore[attr-defined]
|
| 36 |
+
except Exception:
|
| 37 |
+
# If gradio_client internals change, continue without patch; API docs may be unavailable.
|
| 38 |
+
pass
|
| 39 |
|
| 40 |
#################### BEAM PREDICTION #########################}
|
| 41 |
def beam_prediction_task(data_percentage, task_complexity, theme='Dark'):
|
|
|
|
| 752 |
|
| 753 |
# Launch the app
|
| 754 |
if __name__ == "__main__":
|
| 755 |
+
port = int(os.environ.get("GRADIO_SERVER_PORT", os.environ.get("PORT", "7860")))
|
| 756 |
+
host = os.environ.get("GRADIO_SERVER_NAME", "0.0.0.0")
|
| 757 |
+
demo.launch(server_name=host, server_port=port)
|
| 758 |
+
|
requirements.txt
CHANGED
|
@@ -6,5 +6,5 @@ h5py
|
|
| 6 |
scikit-learn
|
| 7 |
matplotlib
|
| 8 |
seaborn
|
| 9 |
-
gradio
|
| 10 |
-
huggingface-hub<0.26.0
|
|
|
|
| 6 |
scikit-learn
|
| 7 |
matplotlib
|
| 8 |
seaborn
|
| 9 |
+
gradio==5.14.0
|
| 10 |
+
huggingface-hub<0.26.0
|