Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
import os
|
| 3 |
import sys
|
| 4 |
import json
|
|
@@ -16,19 +15,55 @@ if "COMFY_ALLOW_VENDORED" not in os.environ:
|
|
| 16 |
os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "0")
|
| 17 |
os.environ.setdefault("TOKENIZERS_PARALLELISM", "false")
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
if not isinstance(schema, dict):
|
| 25 |
return "any"
|
| 26 |
-
return
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
except Exception as _e:
|
| 31 |
-
|
|
|
|
| 32 |
|
| 33 |
try:
|
| 34 |
from install_w4a8 import install as _install_w4a8
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
import json
|
|
|
|
| 15 |
os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "0")
|
| 16 |
os.environ.setdefault("TOKENIZERS_PARALLELISM", "false")
|
| 17 |
|
| 18 |
+
|
| 19 |
+
def _patch_gradio_client():
|
| 20 |
+
import gradio_client.utils as gu
|
| 21 |
+
|
| 22 |
+
patched_any = False
|
| 23 |
+
|
| 24 |
+
orig_get_type = getattr(gu, "get_type", None)
|
| 25 |
+
if orig_get_type is not None and not getattr(orig_get_type, "_w4a8_patched", False):
|
| 26 |
+
def safe_get_type(schema):
|
| 27 |
+
if not isinstance(schema, dict):
|
| 28 |
+
return "any"
|
| 29 |
+
return orig_get_type(schema)
|
| 30 |
+
safe_get_type._w4a8_patched = True
|
| 31 |
+
gu.get_type = safe_get_type
|
| 32 |
+
patched_any = True
|
| 33 |
+
|
| 34 |
+
orig_jstp = getattr(gu, "_json_schema_to_python_type", None)
|
| 35 |
+
if orig_jstp is not None and not getattr(orig_jstp, "_w4a8_patched", False):
|
| 36 |
+
def safe_jstp(schema, defs=None):
|
| 37 |
if not isinstance(schema, dict):
|
| 38 |
return "any"
|
| 39 |
+
return orig_jstp(schema, defs)
|
| 40 |
+
safe_jstp._w4a8_patched = True
|
| 41 |
+
gu._json_schema_to_python_type = safe_jstp
|
| 42 |
+
patched_any = True
|
| 43 |
+
|
| 44 |
+
orig_public = getattr(gu, "json_schema_to_python_type", None)
|
| 45 |
+
if orig_public is not None and not getattr(orig_public, "_w4a8_patched", False):
|
| 46 |
+
def safe_public(schema, defs=None):
|
| 47 |
+
if not isinstance(schema, dict):
|
| 48 |
+
return "any"
|
| 49 |
+
try:
|
| 50 |
+
return orig_public(schema, defs)
|
| 51 |
+
except TypeError:
|
| 52 |
+
return "any"
|
| 53 |
+
safe_public._w4a8_patched = True
|
| 54 |
+
gu.json_schema_to_python_type = safe_public
|
| 55 |
+
patched_any = True
|
| 56 |
+
|
| 57 |
+
return patched_any
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
try:
|
| 61 |
+
_ok = _patch_gradio_client()
|
| 62 |
+
sys.stderr.write(f"[main] gradio_client patch applied={_ok}\n")
|
| 63 |
+
sys.stderr.flush()
|
| 64 |
except Exception as _e:
|
| 65 |
+
sys.stderr.write(f"[main] gradio_client patch FAILED: {type(_e).__name__}: {_e}\n")
|
| 66 |
+
sys.stderr.flush()
|
| 67 |
|
| 68 |
try:
|
| 69 |
from install_w4a8 import install as _install_w4a8
|