bann commited on
Commit
8baf391
·
1 Parent(s): 6f83a93

fix(gradio): apply safe monkey-patch for gradio_client bool schema bug and set api_name=False

Browse files
Files changed (2) hide show
  1. app.py +29 -1
  2. requirements.txt +1 -0
app.py CHANGED
@@ -2,6 +2,34 @@
2
 
3
  from __future__ import annotations
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  import hashlib
6
  import ipaddress
7
  import json
@@ -1004,7 +1032,7 @@ with gr.Blocks(css=custom_css, title="Wan 2.1 / 2.2 Video Studio") as app:
1004
  civitai_api_key,
1005
  ],
1006
  outputs=[output_video, output_report, seed],
1007
- api_name="generate_video",
1008
  )
1009
 
1010
  if __name__ == "__main__":
 
2
 
3
  from __future__ import annotations
4
 
5
+ # Safe monkey-patch for Gradio 5.x schema inspection bug
6
+ try:
7
+ import gradio_client.utils as client_utils
8
+ _orig_get_type = getattr(client_utils, "get_type", None)
9
+ if _orig_get_type is not None:
10
+ def _safe_get_type(schema):
11
+ if isinstance(schema, bool):
12
+ return "boolean"
13
+ if not isinstance(schema, dict):
14
+ return "any"
15
+ return _orig_get_type(schema)
16
+ client_utils.get_type = _safe_get_type
17
+
18
+ _orig_json_schema = getattr(client_utils, "_json_schema_to_python_type", None)
19
+ if _orig_json_schema is not None:
20
+ def _safe_json_schema_to_python_type(schema, defs=None):
21
+ if isinstance(schema, bool):
22
+ return "bool"
23
+ if not isinstance(schema, dict):
24
+ return "Any"
25
+ try:
26
+ return _orig_json_schema(schema, defs)
27
+ except Exception:
28
+ return "Any"
29
+ client_utils._json_schema_to_python_type = _safe_json_schema_to_python_type
30
+ except Exception:
31
+ pass
32
+
33
  import hashlib
34
  import ipaddress
35
  import json
 
1032
  civitai_api_key,
1033
  ],
1034
  outputs=[output_video, output_report, seed],
1035
+ api_name=False,
1036
  )
1037
 
1038
  if __name__ == "__main__":
requirements.txt CHANGED
@@ -4,6 +4,7 @@ accelerate>=1.2.0
4
  sentencepiece
5
  safetensors
6
  gradio>=5.20.0
 
7
  spaces>=0.51.1
8
  imageio[ffmpeg]
9
  torchvision
 
4
  sentencepiece
5
  safetensors
6
  gradio>=5.20.0
7
+ gradio_client>=1.6.0
8
  spaces>=0.51.1
9
  imageio[ffmpeg]
10
  torchvision