Back to Blog
📝 Dev Notes

OpenPaw + ComfyUI 設定指南 — 從零到產圖

B
Blake
May 5, 2026 By Blake 5 min read

給 OpenAB 社群同仁的完整設定教學。照著做就能讓你的 OpenAB bot 產圖。

延伸閱讀:OpenPaw — 用 AI 讓家人每天感受到毛孩的陪伴


你需要什麼

項目

規格

GPU

12GB+ VRAM(RTX 3060 以上)

ComfyUI

已安裝並能跑

模型

Flux.1-schnell(FP8 版本約 10GB)

LoRA

你自己訓練的

OpenAB

已能跑 bot


Step 1: 安裝 ComfyUI

git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
pip install -r requirements.txt
CUDA_VISIBLE_DEVICES=1 python3 main.py --listen 0.0.0.0 --port 8188

驗證:curl http://localhost:8188/system_stats


Step 2: 下載模型

放到 ComfyUI 對應目錄:

  • unet/ → flux1-schnell-fp8-e4m3fn.safetensors

  • clip/ → clip_l.safetensors + t5xxl_fp8_e4m3fn.safetensors

  • vae/ → ae.safetensors

  • loras/ → your-pet.safetensors

下載來源:Hugging Face black-forest-labs/FLUX.1-schnell


Step 3: 訓練 LoRA

照片要求

  • 20+ 張你的寵物照片

  • 各種角度(正面、側面、全身、特寫)

  • 各種場景(室內、室外、不同光線)

  • 清晰、不模糊

訓練指令

cd openpaw/lora/training
./train-lora.sh \
  --images /path/to/pet-photos \
  --output my-pet.safetensors \
  --trigger my_pet \
  --steps 1500 \
  --rank 16

參數:

  • trigger: prompt 裡用這個詞觸發 LoRA

  • steps: 1500 起步,過多會 overfitting

  • rank: 16 平衡品質和大小

訓練完複製到 ComfyUI/models/loras/


Step 4: 測試產圖

cd openpaw/comfyui
./generate-and-send.sh \
  --prompt "my_pet, golden retriever sitting in sunny garden" \
  --platform discord \
  --channel "your-channel-id" \
  --caption "Hello!"

產圖流程:送 workflow → ComfyUI → 等完成 → 下載 → 疊字(可選)→ 送出


Step 5: 串接 OpenAB

CLAUDE.md 加上產圖指令

在你的 agent CLAUDE.md 裡加:

當用戶要求產圖時,執行:
/path/to/openpaw/comfyui/generate-and-send.sh \
  --prompt "my_pet, [場景描述]" \
  --platform [discord|line] \
  --channel "[channel_id]" \
  --caption "[回覆文字]"

config.toml 加環境變數

[agent]
env = { COMFYUI_API_URL = "http://localhost:8188" }

Step 6: Cronjob 產圖

在 cronjob.toml 的 message 裡加「產圖」指示,agent 看到就會呼叫 generate-and-send.sh。


文字疊圖(可選)

generate-and-send.sh 有 caption 參數就會自動用 overlay-text.py 疊上中文字。

需要中文字體:apt install fonts-noto-cjk


Prompt 注意事項

  • 一定加 trigger word

  • 不要人類手指手勢(AI 會變形)

  • 用狗狗自然動作:搖尾巴、歪頭、趴著

  • 好:my_pet, golden retriever lying on grass, happy face

  • 壞:my_pet, dog waving hand


常見問題

ComfyUI 產圖失敗?
確認 ComfyUI 在跑:curl http://localhost:8188/system_stats

LoRA 效果不好?
照片太少(< 15)、太相似、steps 太多(overfitting)或太少

圖片送不到 LINE?
確認 LINE_CHANNEL_ACCESS_TOKEN、GATEWAY_IMAGES_DIR、GATEWAY_PUBLIC_URL 都有設

疊字亂碼?
確認有中文字體:fc-list :lang=zh


完整架構

ComfyUI (:8188) → Flux.1 + LoRA → 產圖
    ↓
generate-and-send.sh → 下載圖 → 疊字 → 存到 gateway
    ↓
LINE Push API / Discord API → 送出
    ↑
OpenAB Agent (CLAUDE.md) → 判斷要不要產圖 → 呼叫 script

有問題到 OpenAB Discord 問:https://discord.gg/DmbhfDZjQS

Enjoyed this article? Show some love!

0
Clap

Enjoyed this article?

Subscribe for engineering notes and AI development insights

We respect your privacy. No spam, unsubscribe anytime.

Share this article

Comments