Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,27 +42,31 @@ except ImportError:
|
|
| 42 |
print("Huggingface Hub not available. Install with: pip install huggingface-hub")
|
| 43 |
|
| 44 |
|
| 45 |
-
#
|
| 46 |
from gradio_workflowbuilder import WorkflowBuilder as _WB
|
| 47 |
|
| 48 |
-
# ===== monkey-patch μμ =====
|
| 49 |
if not getattr(_WB, "_patched_for_custom_palette", False):
|
|
|
|
| 50 |
_orig_init = _WB.__init__
|
| 51 |
def _patched_init(self, *args, custom_palette=None, **kwargs):
|
| 52 |
self._custom_palette = custom_palette or []
|
| 53 |
_orig_init(self, *args, **kwargs)
|
| 54 |
_WB.__init__ = _patched_init
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
| 62 |
return cfg
|
| 63 |
-
|
|
|
|
| 64 |
_WB._patched_for_custom_palette = True
|
| 65 |
-
#
|
|
|
|
| 66 |
|
| 67 |
import json, pathlib
|
| 68 |
|
|
|
|
| 42 |
print("Huggingface Hub not available. Install with: pip install huggingface-hub")
|
| 43 |
|
| 44 |
|
| 45 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 46 |
from gradio_workflowbuilder import WorkflowBuilder as _WB
|
| 47 |
|
|
|
|
| 48 |
if not getattr(_WB, "_patched_for_custom_palette", False):
|
| 49 |
+
# 1) __init__ νμ₯ β custom_palette 보κ΄
|
| 50 |
_orig_init = _WB.__init__
|
| 51 |
def _patched_init(self, *args, custom_palette=None, **kwargs):
|
| 52 |
self._custom_palette = custom_palette or []
|
| 53 |
_orig_init(self, *args, **kwargs)
|
| 54 |
_WB.__init__ = _patched_init
|
| 55 |
|
| 56 |
+
# 2) config μμ± μ νλ νΈ ν©μΉκΈ°
|
| 57 |
+
cfg_method = "_get_config" if hasattr(_WB, "_get_config") else "get_config"
|
| 58 |
+
_orig_get_cfg = getattr(_WB, cfg_method)
|
| 59 |
+
|
| 60 |
+
def _patched_get_cfg(self, *args, **kwargs):
|
| 61 |
+
cfg = _orig_get_cfg(self, *args, **kwargs)
|
| 62 |
+
if getattr(self, "_custom_palette", None):
|
| 63 |
+
cfg["palette"] = cfg.get("palette", []) + self._custom_palette
|
| 64 |
return cfg
|
| 65 |
+
|
| 66 |
+
setattr(_WB, cfg_method, _patched_get_cfg)
|
| 67 |
_WB._patched_for_custom_palette = True
|
| 68 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 69 |
+
|
| 70 |
|
| 71 |
import json, pathlib
|
| 72 |
|