- ComfyUI custom nodes: BridgeInput (11 types) + BridgeOutput
- AnyType wildcard for universal output capture
- Custom server route: GET /comfybridge/results/{prompt_id}
- Python async client (ComfyBridge) + sync wrapper (ComfyBridgeSync)
- Workflow JSON parser and patcher (deepcopy, original unchanged)
- WebSocket completion detection
- BridgeResult container with PIL/bytes helpers
- Examples: basic_text_to_image.py, agent_loop.py
- Unit tests for workflow parser and client
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
"""
|
|
기본 텍스트-이미지 예제.
|
|
|
|
실행 전: ComfyUI에서 sdxl_bridge_template.json 을 열어
|
|
Bridge Input / Output 노드가 연결된 상태로 API Format으로 내보낼 것.
|
|
"""
|
|
|
|
import asyncio
|
|
from comfybridgeio import ComfyBridge
|
|
|
|
|
|
async def main():
|
|
bridge = ComfyBridge(host="localhost", port=8188)
|
|
|
|
print("Running workflow...")
|
|
result = await bridge.run(
|
|
workflow="workflows/sdxl_bridge_template.json",
|
|
inputs={
|
|
"prompt": "a majestic cat in outer space, photorealistic, 8k",
|
|
"negative_prompt": "blurry, low quality, deformed",
|
|
"steps": 20,
|
|
"cfg": 7.0,
|
|
"seed": 12345,
|
|
},
|
|
progress_callback=lambda p: print(f" Progress: {p:.0%}", end="\r"),
|
|
)
|
|
|
|
print(f"\nDone! Available outputs: {result.keys()}")
|
|
|
|
if result.get("output_image"):
|
|
with open("output.png", "wb") as f:
|
|
f.write(result.as_bytes("output_image"))
|
|
print("Saved: output.png")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|