Spaces:
Runtime error
Runtime error
Fix: Certified Gradio 5 setup for ZeroGPU compatibility
Browse files
app.py
CHANGED
|
@@ -1,42 +1,27 @@
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
|
| 4 |
-
# --- PARCHE DE
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
if isinstance(schema, bool):
|
| 23 |
-
return "Any"
|
| 24 |
-
try:
|
| 25 |
-
return original_json_to_python(schema, defs)
|
| 26 |
-
except:
|
| 27 |
-
return "Any"
|
| 28 |
-
|
| 29 |
-
client_utils.json_schema_to_python_type = patched_json_to_python
|
| 30 |
-
client_utils._json_schema_to_python_type = patched_json_to_python
|
| 31 |
-
|
| 32 |
-
import gradio as gr
|
| 33 |
-
# Anulamos la generaci贸n de API en el objeto Blocks
|
| 34 |
-
def fake_get_api_info(self):
|
| 35 |
-
return {"components": {}, "endpoints": {}}
|
| 36 |
-
gr.Blocks.get_api_info = fake_get_api_info
|
| 37 |
-
# -----------------------------------------------------------
|
| 38 |
|
| 39 |
import spaces
|
|
|
|
| 40 |
import torch
|
| 41 |
import numpy as np
|
| 42 |
from PIL import Image
|
|
@@ -118,5 +103,5 @@ with gr.Blocks(title="Image Utility v2.1") as demo:
|
|
| 118 |
v_out = gr.Video(label="Sequence Output")
|
| 119 |
v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
|
| 120 |
|
| 121 |
-
#
|
| 122 |
-
demo.
|
|
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
# --- PARCHE DE COMPATIBILIDAD INVESTIGADO (CR脥TICO) ---
|
| 5 |
+
# Este parche corrige el bug de 'bool' en gradio_client que afecta a Gradio 5
|
| 6 |
+
try:
|
| 7 |
+
import gradio_client.utils as client_utils
|
| 8 |
+
old_get_type = client_utils.get_type
|
| 9 |
+
def new_get_type(schema):
|
| 10 |
+
if isinstance(schema, bool): return "Any"
|
| 11 |
+
return old_get_type(schema)
|
| 12 |
+
client_utils.get_type = new_get_type
|
| 13 |
+
|
| 14 |
+
old_json_to_python = client_utils._json_schema_to_python_type
|
| 15 |
+
def new_json_to_python(schema, defs=None):
|
| 16 |
+
if isinstance(schema, bool): return "Any"
|
| 17 |
+
return old_json_to_python(schema, defs)
|
| 18 |
+
client_utils._json_schema_to_python_type = new_json_to_python
|
| 19 |
+
except Exception as e:
|
| 20 |
+
print(f"Aviso: No se pudo aplicar el parche de gradio_client: {e}")
|
| 21 |
+
# ------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
import spaces
|
| 24 |
+
import gradio as gr
|
| 25 |
import torch
|
| 26 |
import numpy as np
|
| 27 |
from PIL import Image
|
|
|
|
| 103 |
v_out = gr.Video(label="Sequence Output")
|
| 104 |
v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
|
| 105 |
|
| 106 |
+
# Al usar SDK nativo, no definimos server_name ni port. HuggingFace lo inyecta solo.
|
| 107 |
+
demo.launch(show_api=False)
|