openfree commited on
Commit
3e49588
Β·
verified Β·
1 Parent(s): dc86894

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -1
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
  # ---------- μ €μž₯ 둜직 ----------