ComfyUI Bridge
Generate images, faceswap, animate expressions, and do style transfer via a self-hosted ComfyUI instance running on your LAN. No cloud API — your GPU, your models.
Requirements
- - ComfyUI Desktop (or server) running somewhere on your LAN
- ComfyUI Bridge server running on the same machine as ComfyUI (see Setup)
- INLINECODE0 installed on the machine running OpenClaw
Setup
1. Install the bridge server (on your ComfyUI machine)
The bridge is a lightweight FastAPI server that wraps ComfyUI's API:
CODEBLOCK0
2. Configure the skill
Set the bridge URL as an environment variable on your OpenClaw machine:
CODEBLOCK1
Or add it to your LaunchAgent/systemd service environment.
3. Required ComfyUI custom nodes (for all features)
Install via ComfyUI Manager:
- - ReActor — faceswap
- ComfyUI-LivePortrait — expression animation
- ComfyUIIPAdapterplus — style transfer
- WAS Node Suite — utilities
- ComfyUI-GGUF — GGUF model support (optional, for FLUX)
- rgthree-comfy — workflow utilities
4. Recommended models
| Model | Use |
|---|
| Juggernaut XL Ragnarok | Architecture, objects, general |
| RealVisXL V5.0 Lightning |
People, portraits, fast |
| FLUX.1 Dev Q5 GGUF | Maximum photorealism (slow, VRAM-heavy) |
Usage
All commands use the comfyui_generate.py script via uv run. Replace SKILL_SCRIPTS with the path to this skill's scripts/ directory.
Always use --no-media — include one MEDIA: /full/path/to/output.png in your text response instead.
1. Text to Image
CODEBLOCK2
2. Image to Image
CODEBLOCK3
3. Faceswap (pipeline — best quality)
Swaps a face then runs img2img cleanup for natural blending. ~30 seconds total.
CODEBLOCK4
4. Faceswap (basic)
CODEBLOCK5
5. Targeted Faceswap (specific face in group photo)
CODEBLOCK6
Face indices: 0 = leftmost, 1 = second from left, "0,2" = first and third.
6. LivePortrait (expression animation)
CODEBLOCK7
Presets: smile, surprised, wink, suspicious, derp, angry, INLINECODE16
Fine-grained control: --smile (-0.3 to 1.3), --blink-val (-20 to 5), --eyebrow-val (-10 to 15), --aaa (-30 to 120, mouth open), --pitch/--yaw/--roll (-20 to 20, head rotation).
7. Style Transfer
Generate a new image in the style of a reference:
CODEBLOCK8
8. Restyle
Apply a reference image's style to an existing photo:
CODEBLOCK9
9. Enhanced mode
Add --enhanced to any command for FaceDetailer + 4x-UltraSharp upscale (net ~2x resolution). Works with txt2img and faceswap.
Quality Gates (built-in)
The script includes two automatic quality checks on faceswap outputs:
Gate 1 — Size check: ReActor blank outputs when no face is detected (~2KB). Any faceswap output under 10KB automatically retries once. If still blank, exits with FACESWAP_BLANK: error — no garbage delivered.
Gate 2 — Vision QA: If you have Ollama running locally with gemma3:12b, faceswap outputs are checked with vision QA before delivery. PASS → deliver normally. FAIL → file renamed _qa_flagged and still delivered. Add ~10-20s but catches glitchy outputs. Disable by not having Ollama/gemma3 installed (fails open).
Offline Queue
When the bridge is unreachable, requests are automatically queued to ~/.openclaw/faceswap-queue/. A companion daemon (queue_processor.py) polls every 5 minutes and delivers via iMessage when the bridge comes back online.
Tell users: "Got it — the system is offline right now but your request is queued and will be sent automatically when it comes back."
Options Reference
| Flag | Default | Description |
|---|
| INLINECODE30 / INLINECODE31 | — | Text description |
| INLINECODE32 / INLINECODE33 |
required | Output path (use
~/.openclaw/media/outbound/) |
|
-i /
--input-image | — | Input image (img2img target / faceswap target / portrait) |
|
--source-face | — | Source face image (faceswap modes) |
|
--faceswap | false | Basic faceswap |
|
--faceswap-pipeline | false | Faceswap + cleanup (best quality) |
|
--cleanup-strength |
0.40 | Pipeline cleanup denoise strength |
|
--targeted-faceswap | false | Swap specific face in multi-face image |
|
--target-face-index |
0 | Which face(s) to replace (comma-separated) |
|
--liveportrait | false | Expression animation mode |
|
--expression-preset | — | smile / surprised / wink / suspicious / derp / angry / sleepy |
|
--style-transfer | false | Generate in reference style |
|
--restyle | false | Apply reference style to existing photo |
|
--style-ref | — | Style reference image |
|
--style-weight |
0.85 | Style influence (0.5–1.0) |
|
--model /
-m |
juggernaut |
juggernaut,
flux,
realvis |
|
--aspect-ratio /
-a |
1:1 |
1:1,
4:5,
9:16,
16:9,
5:4 |
|
--strength /
-s |
0.6 | img2img denoise strength |
|
--seed |
-1 | Seed (-1 = random) |
|
--enhanced /
-e | false | FaceDetailer + 4x upscale |
|
--no-media | false | Suppress MEDIA: stdout line (always use this) |
Routing Guide
| User says | Mode |
|---|
| "generate an image of..." | txt2img |
| "make this look like..." (with image) |
img2img |
| "put [person]'s face on this" | --faceswap-pipeline |
| "swap the second face" | --targeted-faceswap --target-face-index 1 |
| "make him smile / look surprised" | --liveportrait --expression-preset |
| "generate something that looks like this painting" | --style-transfer |
| "make this photo look like a painting" | --restyle |
| "high quality / best quality" | add --enhanced |
Timing Reference
| Mode | Approximate time |
|---|
| txt2img (realvis) | ~5 seconds |
| txt2img (juggernaut) |
~5 minutes |
| txt2img (flux) | ~10 minutes |
| faceswap pipeline | ~30 seconds |
| liveportrait | ~7 seconds (21s first run) |
| style transfer / restyle | ~5 minutes |
| +enhanced | +10-30 seconds |
ComfyUI Bridge
通过局域网内自托管的 ComfyUI 实例生成图像、换脸、表情动画和风格迁移。无需云 API——使用你自己的 GPU 和模型。
系统要求
- - 在局域网某处运行的 ComfyUI 桌面版(或服务器)
- 在与 ComfyUI 相同的机器上运行 ComfyUI Bridge 服务器(参见设置)
- 在运行 OpenClaw 的机器上安装 uv
设置
1. 安装桥接服务器(在你的 ComfyUI 机器上)
桥接服务器是一个轻量级的 FastAPI 服务器,封装了 ComfyUI 的 API:
bash
git clone https://github.com/Bortlesboat/comfyui-bridge
cd comfyui-bridge
pip install -r requirements.txt
python bridge_server.py
监听于 http://0.0.0.0:8100
2. 配置技能
在你的 OpenClaw 机器上将桥接 URL 设置为环境变量:
bash
export COMFYUIBRIDGEURL=http://你的COMFYUI机器_IP:8100
或者将其添加到你的 LaunchAgent/systemd 服务环境中。
3. 必需的 ComfyUI 自定义节点(用于所有功能)
通过 ComfyUI Manager 安装:
- - ReActor — 换脸
- ComfyUI-LivePortrait — 表情动画
- ComfyUIIPAdapterplus — 风格迁移
- WAS Node Suite — 工具集
- ComfyUI-GGUF — GGUF 模型支持(可选,用于 FLUX)
- rgthree-comfy — 工作流工具
4. 推荐模型
| 模型 | 用途 |
|---|
| Juggernaut XL Ragnarok | 建筑、物体、通用 |
| RealVisXL V5.0 Lightning |
人物、肖像、快速 |
| FLUX.1 Dev Q5 GGUF | 极致逼真(慢、高显存占用) |
使用方法
所有命令均通过 uv run 使用 comfyuigenerate.py 脚本。将 SKILLSCRIPTS 替换为此技能 scripts/ 目录的路径。
始终使用 --no-media — 改为在文本回复中包含一个 MEDIA: /完整/路径/到/output.png。
1. 文生图
bash
uv run $SKILLSCRIPTS/comfyuigenerate.py \
--prompt 你的描述 \
--filename ~/.openclaw/media/outbound/output.png \
--no-media
2. 图生图
bash
uv run $SKILLSCRIPTS/comfyuigenerate.py \
--prompt 改成日落效果 \
-i /路径/到/input.png \
--strength 0.5 \
--filename ~/.openclaw/media/outbound/output.png \
--no-media
3. 换脸(流水线 — 最佳质量)
先换脸,再运行 img2img 清理以实现自然融合。总共约 30 秒。
bash
uv run $SKILLSCRIPTS/comfyuigenerate.py \
--faceswap-pipeline \
--source-face /路径/到/source_face.png \
-i /路径/到/target.png \
--cleanup-strength 0.40 \
--filename ~/.openclaw/media/outbound/output.png \
--no-media
4. 换脸(基础版)
bash
uv run $SKILLSCRIPTS/comfyuigenerate.py \
--faceswap \
--source-face /路径/到/source_face.png \
-i /路径/到/target.png \
--filename ~/.openclaw/media/outbound/output.png \
--no-media
5. 定向换脸(群像中的特定人脸)
bash
uv run $SKILLSCRIPTS/comfyuigenerate.py \
--targeted-faceswap \
--source-face /路径/到/source_face.png \
-i /路径/到/group_photo.png \
--target-face-index 1 \
--filename ~/.openclaw/media/outbound/output.png \
--no-media
人脸索引:0 = 最左侧,1 = 左数第二个,0,2 = 第一个和第三个。
6. LivePortrait(表情动画)
bash
uv run $SKILLSCRIPTS/comfyuigenerate.py \
--liveportrait \
-i /路径/到/portrait.png \
--expression-preset smile \
--filename ~/.openclaw/media/outbound/output.png \
--no-media
预设:smile(微笑)、surprised(惊讶)、wink(眨眼)、suspicious(怀疑)、derp(呆滞)、angry(生气)、sleepy(困倦)
精细控制:--smile(-0.3 到 1.3)、--blink-val(-20 到 5)、--eyebrow-val(-10 到 15)、--aaa(-30 到 120,张嘴)、--pitch/--yaw/--roll(-20 到 20,头部旋转)。
7. 风格迁移
以参考图像的风格生成新图像:
bash
uv run $SKILLSCRIPTS/comfyuigenerate.py \
--style-transfer \
--style-ref /路径/到/reference.png \
--prompt 一个男人的肖像 \
--style-weight 0.85 \
--filename ~/.openclaw/media/outbound/output.png \
--no-media
8. 风格重绘
将参考图像的风格应用到现有照片上:
bash
uv run $SKILLSCRIPTS/comfyuigenerate.py \
--restyle \
--style-ref /路径/到/reference.png \
-i /路径/到/photo.png \
--style-weight 0.85 \
--strength 0.65 \
--filename ~/.openclaw/media/outbound/output.png \
--no-media
9. 增强模式
在任何命令中添加 --enhanced 以启用 FaceDetailer + 4x-UltraSharp 放大(净分辨率提升约 2 倍)。适用于 txt2img 和换脸。
质量门控(内置)
脚本包含两个针对换脸输出的自动质量检查:
门控 1 — 大小检查: 当未检测到人脸时,ReActor 输出空白图像(约 2KB)。任何小于 10KB 的换脸输出会自动重试一次。如果仍然空白,则退出并显示 FACESWAP_BLANK: 错误——不会输出垃圾结果。
门控 2 — 视觉质量检查: 如果你在本地运行了 Ollama 并带有 gemma3:12b 模型,换脸输出在交付前会经过视觉质量检查。通过 → 正常交付。失败 → 文件重命名为 qa_flagged 但仍会交付。增加约 10-20 秒,但能捕获有问题的输出。如果不安装 Ollama/gemma3 则禁用此功能(安全失败)。
离线队列
当桥接服务器不可达时,请求会自动排队到 ~/.openclaw/faceswap-queue/。一个伴随后台守护进程(queue_processor.py)每 5 分钟轮询一次,并在桥接服务器重新上线时通过 iMessage 交付。
告知用户:收到——系统当前处于离线状态,但你的请求已加入队列,待系统恢复后将自动发送。
选项参考
| 标志 | 默认值 | 描述 |
|---|
| --prompt / -p | — | 文本描述 |
| --filename / -f |
必需 | 输出路径(使用 ~/.openclaw/media/outbound/) |
| -i / --input-image | — | 输入图像(img2img 目标 / 换脸目标 / 肖像) |
| --source-face | — | 源人脸图像(换脸模式) |
| --faceswap | false | 基础换脸 |
| --faceswap-pipeline | false | 换脸 + 清理(最佳质量) |
| --cleanup-strength | 0.40 | 流水线清理去噪强度 |
| --targeted-faceswap | false | 在多脸图像中替换特定人脸 |
| --