Spaces:
Sleeping
Sleeping
ibcplateformes Claude Opus 4.6 commited on
Commit ·
888e081
1
Parent(s): 14442a3
Fix gradio 4.44.0 crashes: replace Dataframe with HTML + better patch
Browse files- Replace gr.Dataframe with gr.HTML to avoid additionalProperties schema bug
- Fix monkey-patch: delete additionalProperties key instead of replacing
with dict (which caused jinja2 unhashable type error)
- Patch get_type() to handle bool schemas
- Revert to gradio 4.44.0 (HF Spaces default)
- Remove gradio_client pin that caused conflicts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- README.md +1 -1
- app.py +21 -14
- requirements.txt +1 -2
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: "\U0001F3A4"
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 4.44.
|
| 8 |
python_version: "3.10"
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.0
|
| 8 |
python_version: "3.10"
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
app.py
CHANGED
|
@@ -18,22 +18,30 @@ import gradio as gr
|
|
| 18 |
try:
|
| 19 |
import gradio_client.utils as _gc_utils
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
def
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
if isinstance(schema, bool):
|
| 26 |
return "Any"
|
| 27 |
if isinstance(schema, dict) and "additionalProperties" in schema:
|
| 28 |
ap = schema["additionalProperties"]
|
| 29 |
if isinstance(ap, bool):
|
| 30 |
-
schema = dict(schema)
|
| 31 |
-
schema["additionalProperties"]
|
| 32 |
-
return
|
| 33 |
|
| 34 |
-
_gc_utils._json_schema_to_python_type =
|
| 35 |
except Exception:
|
| 36 |
-
pass
|
| 37 |
|
| 38 |
# Setup logging
|
| 39 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
|
@@ -185,11 +193,12 @@ def convert_song(
|
|
| 185 |
# ── Models Tab ───────────────────────────────────────────────────────────────
|
| 186 |
|
| 187 |
def refresh_models():
|
| 188 |
-
"""Refresh the model list."""
|
| 189 |
models = list_models()
|
| 190 |
if not models:
|
| 191 |
-
return
|
| 192 |
-
|
|
|
|
| 193 |
|
| 194 |
|
| 195 |
def delete_selected_model(model_name_to_delete):
|
|
@@ -404,10 +413,8 @@ with gr.Blocks(
|
|
| 404 |
with gr.TabItem("Mes modèles"):
|
| 405 |
gr.Markdown("### Gérer vos modèles vocaux")
|
| 406 |
|
| 407 |
-
models_table = gr.
|
| 408 |
-
headers=["Nom", "Statut"],
|
| 409 |
value=refresh_models(),
|
| 410 |
-
interactive=False,
|
| 411 |
label="Modèles entraînés",
|
| 412 |
)
|
| 413 |
|
|
|
|
| 18 |
try:
|
| 19 |
import gradio_client.utils as _gc_utils
|
| 20 |
|
| 21 |
+
_original_get_type = _gc_utils.get_type
|
| 22 |
|
| 23 |
+
def _patched_get_type(schema):
|
| 24 |
+
if isinstance(schema, bool):
|
| 25 |
+
return "Any"
|
| 26 |
+
return _original_get_type(schema)
|
| 27 |
+
|
| 28 |
+
_gc_utils.get_type = _patched_get_type
|
| 29 |
+
|
| 30 |
+
_original_json_schema = _gc_utils._json_schema_to_python_type
|
| 31 |
+
|
| 32 |
+
def _patched_json_schema(schema, defs=None):
|
| 33 |
if isinstance(schema, bool):
|
| 34 |
return "Any"
|
| 35 |
if isinstance(schema, dict) and "additionalProperties" in schema:
|
| 36 |
ap = schema["additionalProperties"]
|
| 37 |
if isinstance(ap, bool):
|
| 38 |
+
schema = dict(schema)
|
| 39 |
+
del schema["additionalProperties"]
|
| 40 |
+
return _original_json_schema(schema, defs)
|
| 41 |
|
| 42 |
+
_gc_utils._json_schema_to_python_type = _patched_json_schema
|
| 43 |
except Exception:
|
| 44 |
+
pass
|
| 45 |
|
| 46 |
# Setup logging
|
| 47 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
|
|
|
| 193 |
# ── Models Tab ───────────────────────────────────────────────────────────────
|
| 194 |
|
| 195 |
def refresh_models():
|
| 196 |
+
"""Refresh the model list as HTML."""
|
| 197 |
models = list_models()
|
| 198 |
if not models:
|
| 199 |
+
return "<p style='color:gray;'>Aucun modèle entraîné</p>"
|
| 200 |
+
rows = "".join(f"<tr><td>{m}</td><td>Disponible</td></tr>" for m in models)
|
| 201 |
+
return f"<table style='width:100%;border-collapse:collapse;'><tr><th style='text-align:left;border-bottom:1px solid #555;padding:8px;'>Nom</th><th style='text-align:left;border-bottom:1px solid #555;padding:8px;'>Statut</th></tr>{rows}</table>"
|
| 202 |
|
| 203 |
|
| 204 |
def delete_selected_model(model_name_to_delete):
|
|
|
|
| 413 |
with gr.TabItem("Mes modèles"):
|
| 414 |
gr.Markdown("### Gérer vos modèles vocaux")
|
| 415 |
|
| 416 |
+
models_table = gr.HTML(
|
|
|
|
| 417 |
value=refresh_models(),
|
|
|
|
| 418 |
label="Modèles entraînés",
|
| 419 |
)
|
| 420 |
|
requirements.txt
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
# Gradio + HuggingFace
|
| 2 |
-
gradio==4.44.
|
| 3 |
-
gradio_client==1.3.0
|
| 4 |
spaces
|
| 5 |
huggingface_hub>=0.23.0
|
| 6 |
|
|
|
|
| 1 |
# Gradio + HuggingFace
|
| 2 |
+
gradio==4.44.0
|
|
|
|
| 3 |
spaces
|
| 4 |
huggingface_hub>=0.23.0
|
| 5 |
|