Spaces:
Runtime error
Runtime error
Fix: Runtime memory injection for gradio_client stability
Browse files
app.py
CHANGED
|
@@ -1,26 +1,42 @@
|
|
| 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 |
-
import spaces
|
| 23 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
import torch
|
| 25 |
import numpy as np
|
| 26 |
from PIL import Image
|
|
@@ -102,4 +118,5 @@ with gr.Blocks(title="Image Utility v2.1") as demo:
|
|
| 102 |
v_out = gr.Video(label="Sequence Output")
|
| 103 |
v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
|
| 104 |
|
| 105 |
-
|
|
|
|
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
# --- PARCHE DE EMERGENCIA DE NIVEL 3 (INYECCI脫N DE MEMORIA) ---
|
| 5 |
+
import gradio_client.utils as client_utils
|
| 6 |
+
|
| 7 |
+
# Guardamos la funci贸n original por si acaso
|
| 8 |
+
original_get_type = client_utils.get_type
|
| 9 |
+
|
| 10 |
+
def patched_get_type(schema):
|
| 11 |
+
# Si el esquema es un booleano (el error detectado), devolvemos "Any" y evitamos el colapso
|
| 12 |
+
if isinstance(schema, bool):
|
| 13 |
+
return "Any"
|
| 14 |
+
return original_get_type(schema)
|
| 15 |
+
|
| 16 |
+
# Inyectamos nuestro parche directamente en la librer铆a cargada
|
| 17 |
+
client_utils.get_type = patched_get_type
|
| 18 |
+
|
| 19 |
+
# Tambi茅n parcheamos la funci贸n recursiva para mayor seguridad
|
| 20 |
+
original_json_to_python = client_utils.json_schema_to_python_type
|
| 21 |
+
def patched_json_to_python(schema, defs=None):
|
| 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 |
v_out = gr.Video(label="Sequence Output")
|
| 119 |
v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
|
| 120 |
|
| 121 |
+
# Lanzamiento forzado para evitar el error de localhost
|
| 122 |
+
demo.queue().launch(server_name="0.0.0.0", server_port=7860, show_api=False, share=False)
|