Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,6 +41,35 @@ except ImportError:
|
|
| 41 |
HF_HUB_AVAILABLE = False
|
| 42 |
print("Huggingface Hub not available. Install with: pip install huggingface-hub")
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
# -------------------------------------------------------------------
|
| 45 |
# π οΈ ν¬νΌ ν¨μλ€
|
| 46 |
# -------------------------------------------------------------------
|
|
@@ -1065,7 +1094,9 @@ with gr.Blocks(title="π MOUSE Workflow", theme=gr.themes.Soft(), css=CSS) as
|
|
| 1065 |
label="",
|
| 1066 |
info="Drag nodes β Connect edges β Edit properties β Auto-save!",
|
| 1067 |
value=workflow_value,
|
| 1068 |
-
elem_id="main_workflow"
|
|
|
|
|
|
|
| 1069 |
)
|
| 1070 |
|
| 1071 |
# ---------- μ μ₯ λ‘μ§ ----------
|
|
|
|
| 41 |
HF_HUB_AVAILABLE = False
|
| 42 |
print("Huggingface Hub not available. Install with: pip install huggingface-hub")
|
| 43 |
|
| 44 |
+
|
| 45 |
+
# app.py 맨 μ
|
| 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 |
+
_orig_get_config = _WB._get_config
|
| 57 |
+
def _patched_get_config(self):
|
| 58 |
+
cfg = _orig_get_config(self)
|
| 59 |
+
if self._custom_palette:
|
| 60 |
+
cfg["palette"] = (cfg.get("palette", []) +
|
| 61 |
+
self._custom_palette)
|
| 62 |
+
return cfg
|
| 63 |
+
_WB._get_config = _patched_get_config
|
| 64 |
+
_WB._patched_for_custom_palette = True
|
| 65 |
+
# ===== monkey-patch λ =====
|
| 66 |
+
|
| 67 |
+
import json, pathlib
|
| 68 |
+
|
| 69 |
+
palette_path = pathlib.Path(__file__).parent / "best_ai_palette.json"
|
| 70 |
+
with open(palette_path, "r", encoding="utf-8") as f:
|
| 71 |
+
best_ai_palette = json.load(f)
|
| 72 |
+
|
| 73 |
# -------------------------------------------------------------------
|
| 74 |
# π οΈ ν¬νΌ ν¨μλ€
|
| 75 |
# -------------------------------------------------------------------
|
|
|
|
| 1094 |
label="",
|
| 1095 |
info="Drag nodes β Connect edges β Edit properties β Auto-save!",
|
| 1096 |
value=workflow_value,
|
| 1097 |
+
elem_id="main_workflow",
|
| 1098 |
+
custom_palette=best_ai_palette # β μλ‘ μΆκ°
|
| 1099 |
+
|
| 1100 |
)
|
| 1101 |
|
| 1102 |
# ---------- μ μ₯ λ‘μ§ ----------
|