areebsatin commited on
Commit
092f2f4
·
1 Parent(s): d928682

Fix: monkey-patch gradio_client bool schema crash + bind 0.0.0.0 for HF Spaces

Browse files
Files changed (1) hide show
  1. app.py +42 -1
app.py CHANGED
@@ -1,5 +1,42 @@
1
  """4K Upscaler Pro — Premium AI-powered upscaler with Lumina Synth design."""
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  import gradio as gr
4
  from core import upscale_image, upscale_video
5
 
@@ -656,4 +693,8 @@ For private spaces, add:
656
 
657
  # ── Launch ──
658
  if __name__ == "__main__":
659
- demo.queue(max_size=5).launch(ssr_mode=False)
 
 
 
 
 
1
  """4K Upscaler Pro — Premium AI-powered upscaler with Lumina Synth design."""
2
 
3
+ # ── Monkey-patch gradio_client to fix bool schema crash ─────────────
4
+ # Gradio 5.x generates JSON schemas with `additionalProperties: False`
5
+ # (a boolean). The gradio_client parser tries `"const" in schema` on it,
6
+ # which crashes with TypeError because you can't do `"x" in False`.
7
+ import gradio_client.utils as _gc_utils
8
+
9
+ _original_json_schema_to_python_type = _gc_utils._json_schema_to_python_type
10
+
11
+
12
+ def _patched_json_schema_to_python_type(schema, defs=None):
13
+ """Safe wrapper that handles bool schemas."""
14
+ if isinstance(schema, bool):
15
+ return "Any"
16
+ # Guard against additionalProperties being bool
17
+ if isinstance(schema, dict) and "additionalProperties" in schema:
18
+ if isinstance(schema["additionalProperties"], bool):
19
+ schema = {k: v for k, v in schema.items() if k != "additionalProperties"}
20
+ return _original_json_schema_to_python_type(schema, defs)
21
+
22
+
23
+ _gc_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
24
+
25
+ _original_get_type = _gc_utils.get_type
26
+
27
+
28
+ def _patched_get_type(schema):
29
+ """Safe wrapper that handles bool schemas in get_type."""
30
+ if isinstance(schema, bool):
31
+ return "Any"
32
+ if not isinstance(schema, dict):
33
+ return "Any"
34
+ return _original_get_type(schema)
35
+
36
+
37
+ _gc_utils.get_type = _patched_get_type
38
+ # ── End monkey-patch ────────────────────────────────────────────────
39
+
40
  import gradio as gr
41
  from core import upscale_image, upscale_video
42
 
 
693
 
694
  # ── Launch ──
695
  if __name__ == "__main__":
696
+ demo.queue(max_size=5).launch(
697
+ ssr_mode=False,
698
+ server_name="0.0.0.0",
699
+ server_port=7860,
700
+ )