keinne commited on
Commit
2db49aa
·
verified ·
1 Parent(s): c09b05c

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -4,6 +4,7 @@ import os
4
  from uuid import uuid4
5
 
6
  import gradio as gr
 
7
 
8
  ROOT = Path(__file__).resolve().parent
9
  SRC = ROOT / "src"
@@ -14,6 +15,21 @@ from dot2dot.pipeline import DotToDotPipeline
14
  from dot2dot.config import AGE_PRESETS, KDP_DEFAULTS
15
 
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  PIPELINE = DotToDotPipeline()
18
  RUNS_DIR = Path("/tmp/dot2dot_runs")
19
  RUNS_DIR.mkdir(parents=True, exist_ok=True)
 
4
  from uuid import uuid4
5
 
6
  import gradio as gr
7
+ import gradio_client.utils as gr_client_utils
8
 
9
  ROOT = Path(__file__).resolve().parent
10
  SRC = ROOT / "src"
 
15
  from dot2dot.config import AGE_PRESETS, KDP_DEFAULTS
16
 
17
 
18
+ def _patch_gradio_bool_schema_bug() -> None:
19
+ original_get_type = gr_client_utils.get_type
20
+
21
+ def patched_get_type(schema):
22
+ # Gradio 4.44.x can crash on API schema generation when JSON Schema
23
+ # uses a bare boolean for additionalProperties.
24
+ if isinstance(schema, bool):
25
+ return "boolean"
26
+ return original_get_type(schema)
27
+
28
+ gr_client_utils.get_type = patched_get_type
29
+
30
+
31
+ _patch_gradio_bool_schema_bug()
32
+
33
  PIPELINE = DotToDotPipeline()
34
  RUNS_DIR = Path("/tmp/dot2dot_runs")
35
  RUNS_DIR.mkdir(parents=True, exist_ok=True)