Spaces:
Running
Running
changes made to app.py
Browse files
app.py
CHANGED
@@ -6,28 +6,29 @@ import os
|
|
6 |
import gradio_client.utils as client_utils
|
7 |
import sys
|
8 |
|
9 |
-
#
|
10 |
-
#
|
11 |
-
|
12 |
-
|
13 |
def _patched_json_schema_to_python_type(schema, defs=None, depth=0):
|
14 |
-
|
|
|
15 |
return "Any"
|
|
|
|
|
16 |
if isinstance(schema, bool):
|
17 |
return "Any" if schema else "None"
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
19 |
|
|
|
20 |
client_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
|
21 |
-
sys.setrecursionlimit(10000) # Temporarily increase recursion depth
|
22 |
-
# ================== FIX END ====================
|
23 |
|
24 |
-
#
|
25 |
-
|
26 |
-
if isinstance(schema, bool):
|
27 |
-
return "Any" if schema else "None"
|
28 |
-
return client_utils._json_schema_to_python_type(schema, defs)
|
29 |
-
|
30 |
-
client_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
|
31 |
|
32 |
# Set up device
|
33 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
6 |
import gradio_client.utils as client_utils
|
7 |
import sys
|
8 |
|
9 |
+
# ===============================
|
10 |
+
# Recursion Handling Fix
|
11 |
+
# ===============================
|
|
|
12 |
def _patched_json_schema_to_python_type(schema, defs=None, depth=0):
|
13 |
+
# Safety check to prevent infinite recursion
|
14 |
+
if depth > 100:
|
15 |
return "Any"
|
16 |
+
|
17 |
+
# Handle boolean cases
|
18 |
if isinstance(schema, bool):
|
19 |
return "Any" if schema else "None"
|
20 |
+
|
21 |
+
# Call the original function with increased depth
|
22 |
+
try:
|
23 |
+
return client_utils._json_schema_to_python_type(schema, defs)
|
24 |
+
except RecursionError:
|
25 |
+
return "Any"
|
26 |
|
27 |
+
# Modify the utilities to use the patched function
|
28 |
client_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
|
|
|
|
|
29 |
|
30 |
+
# Increase recursion limit as a backup
|
31 |
+
sys.setrecursionlimit(10000)
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
# Set up device
|
34 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|