cobramv12 commited on
Commit
db24426
verified
1 Parent(s): 44a8e2d

Fix: Master patch for gradio_client bool bug and localhost accessibility

Browse files
Files changed (1) hide show
  1. app.py +26 -3
app.py CHANGED
@@ -1,7 +1,29 @@
1
  import sys
2
  import os
3
 
4
- # --- PARCHES DE COMPATIBILIDAD CERTIFICADOS ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  try:
6
  import huggingface_hub
7
  class MockHfFolder:
@@ -21,7 +43,7 @@ try:
21
  except:
22
  from unittest.mock import MagicMock
23
  sys.modules["audioop"] = MagicMock()
24
- # ----------------------------------------------
25
 
26
  import spaces
27
  import gradio as gr
@@ -110,4 +132,5 @@ with gr.Blocks(title="Image Utility v2.1") as demo:
110
  v_out = gr.Video(label="Sequence Output")
111
  v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
112
 
113
- demo.queue().launch(show_api=False)
 
 
1
  import sys
2
  import os
3
 
4
+ # --- PARCHE QUIR脷RGICO PARA EL BUG 'BOOL' (ERROR REAL DETECTADO) ---
5
+ try:
6
+ import gradio_client.utils as client_utils
7
+ # Parcheamos la funci贸n que causa el TypeError: argument of type 'bool' is not iterable
8
+ old_json_schema_to_python_type = client_utils._json_schema_to_python_type
9
+ def patched_json_schema_to_python_type(schema, defs=None):
10
+ if isinstance(schema, bool):
11
+ return "Any"
12
+ return old_json_schema_to_python_type(schema, defs)
13
+ client_utils._json_schema_to_python_type = patched_json_schema_to_python_type
14
+
15
+ if hasattr(client_utils, "get_type"):
16
+ old_get_type = client_utils.get_type
17
+ def patched_get_type(schema):
18
+ if isinstance(schema, bool):
19
+ return "Any"
20
+ return old_get_type(schema)
21
+ client_utils.get_type = patched_get_type
22
+ print("Gradio Client 'bool' patch applied successfully.")
23
+ except Exception as e:
24
+ print(f"Failed to apply Gradio Client patch: {e}")
25
+
26
+ # --- PARCHES DE COMPATIBILIDAD (HfFolder + audioop) ---
27
  try:
28
  import huggingface_hub
29
  class MockHfFolder:
 
43
  except:
44
  from unittest.mock import MagicMock
45
  sys.modules["audioop"] = MagicMock()
46
+ # -----------------------------------------------------------------
47
 
48
  import spaces
49
  import gradio as gr
 
132
  v_out = gr.Video(label="Sequence Output")
133
  v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
134
 
135
+ # server_name 0.0.0.0 es clave para evitar el error de localhost en HF
136
+ demo.queue().launch(show_api=False, server_name="0.0.0.0", server_port=7860)