Raghu commited on
Commit
05779db
·
1 Parent(s): b75eec8

Handle bool in gradio json schema get_type to restore API

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -8,7 +8,6 @@ import torch
8
  import torch.nn as nn
9
  import numpy as np
10
  import gradio as gr
11
- import gradio.routes as gr_routes
12
  import easyocr
13
  import json
14
  import re
@@ -21,10 +20,17 @@ import warnings
21
  warnings.filterwarnings('ignore')
22
 
23
  # ---------------------------------------------------------------------------
24
- # Work around Gradio json_schema traversal crash on Spaces by disabling API info
25
  # ---------------------------------------------------------------------------
26
- gr_routes.api_info = lambda serialize=True: {}
27
- gr.Blocks.get_api_info = lambda self: {}
 
 
 
 
 
 
 
28
 
29
  # ============================================================================
30
  # Configuration
 
8
  import torch.nn as nn
9
  import numpy as np
10
  import gradio as gr
 
11
  import easyocr
12
  import json
13
  import re
 
20
  warnings.filterwarnings('ignore')
21
 
22
  # ---------------------------------------------------------------------------
23
+ # Work around Gradio json_schema traversal crash: guard bool schema entries
24
  # ---------------------------------------------------------------------------
25
+ import gradio_client.utils as grc_utils
26
+ _orig_get_type = grc_utils.get_type
27
+
28
+ def _safe_get_type(schema):
29
+ if isinstance(schema, bool):
30
+ return "any"
31
+ return _orig_get_type(schema)
32
+
33
+ grc_utils.get_type = _safe_get_type
34
 
35
  # ============================================================================
36
  # Configuration