Spaces:
Runtime error
Runtime error
Fix: Use ComfyUI's built-in /workflow/convert endpoint for proper widget handling
Browse files
app.py
CHANGED
|
@@ -217,7 +217,7 @@ def remove_watermark(input_image):
|
|
| 217 |
raise RuntimeError("ComfyUI server failed to start. Port 8188 remained closed.")
|
| 218 |
|
| 219 |
try:
|
| 220 |
-
# 3.
|
| 221 |
workflow_path = os.path.join(BYPASS_REPO_DIR, "Synthid_Bypass.json")
|
| 222 |
with open(workflow_path, 'r') as f:
|
| 223 |
web_wf = json.load(f)
|
|
@@ -226,9 +226,16 @@ def remove_watermark(input_image):
|
|
| 226 |
for node in web_wf.get("nodes", []):
|
| 227 |
if node.get("id") == 11:
|
| 228 |
node["widgets_values"] = [input_filename, "image"]
|
| 229 |
-
|
| 230 |
-
#
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
|
| 233 |
print("Queueing prompt to ComfyUI...")
|
| 234 |
prompt_data = {"prompt": api_prompt}
|
|
|
|
| 217 |
raise RuntimeError("ComfyUI server failed to start. Port 8188 remained closed.")
|
| 218 |
|
| 219 |
try:
|
| 220 |
+
# 3. Load workflow and convert using ComfyUI's built-in converter
|
| 221 |
workflow_path = os.path.join(BYPASS_REPO_DIR, "Synthid_Bypass.json")
|
| 222 |
with open(workflow_path, 'r') as f:
|
| 223 |
web_wf = json.load(f)
|
|
|
|
| 226 |
for node in web_wf.get("nodes", []):
|
| 227 |
if node.get("id") == 11:
|
| 228 |
node["widgets_values"] = [input_filename, "image"]
|
| 229 |
+
|
| 230 |
+
# Use ComfyUI's built-in /workflow/convert endpoint for proper conversion
|
| 231 |
+
print("Converting workflow to API format...")
|
| 232 |
+
convert_resp = requests.post("http://127.0.0.1:8188/workflow/convert", json=web_wf)
|
| 233 |
+
|
| 234 |
+
if convert_resp.status_code != 200:
|
| 235 |
+
raise RuntimeError(f"Failed to convert workflow: {convert_resp.text}")
|
| 236 |
+
|
| 237 |
+
api_prompt = convert_resp.json()
|
| 238 |
+
print(f"Workflow converted successfully ({len(api_prompt)} nodes)")
|
| 239 |
|
| 240 |
print("Queueing prompt to ComfyUI...")
|
| 241 |
prompt_data = {"prompt": api_prompt}
|