name: text-to-image description: 使用本地 ComfyUI 生成圖片的技能。當用戶提到文生圖、生成圖片、畫一張、AI 繪圖、文字轉圖片、text to image、prompt 生成圖片、用文字生出圖片,或任何通過文字描述生成圖片的需求時,都應使用本 Skill。即使使用者沒有明確說"ComfyUI",只要意圖是通過本地模型將文字描述變成圖片,就應觸發。支援選擇模型、設定解析度、調整取樣引數、返回生成圖片 URL。
通過本地部署的 ComfyUI(預設 http://127.0.0.1:8188)實現文本到圖片的生成。Skill 封裝了提交任務、輪詢進度、提取結果 URL 的完整流程,讓你只需關注 Prompt 描述和引數調優。
scripts/comfyui_api.py 提交生成任務| 引數 | 必填 | 預設值 | 說明 |
|---|---|---|---|
prompt |
是 | — | 正向提示詞,描述你想生成的圖片內容 |
negative_prompt |
否 | "" |
反向提示詞,描述你想避免的內容 |
width |
否 | 1024 |
圖片寬度(畫素) |
height |
否 | 1024 |
圖片高度(畫素) |
steps |
否 | 20 |
取樣步數,越大越精細但越慢 |
cfg_scale |
否 | 7.0 |
CFG 引導係數,控制 Prompt 對生成結果的引導強度 |
seed |
否 | -1 |
隨機種子,-1 表示隨機 |
sampler_name |
否 | euler |
取樣器名稱 |
scheduler |
否 | normal |
排程器型別 |
checkpoint |
否 | — | 模型檢查點名稱,留空則使用 ComfyUI 當前載入的模型 |
comfyui_url |
否 | http://127.0.0.1:8188 |
ComfyUI 服務地址 |
好的 Prompt 是文生圖質量的關鍵。寫 Prompt 時注意以下幾點:
小蔥技能7w4.net有更新,你可以訪問看下。
masterpiece, best quality, highly detailed, 8knegative_prompt 排除不想要的元素,常見的選擇如 lowres, bad anatomy, bad hands, cropped, worst quality示例 1:寫實風格
- Prompt: a white kitten sitting on a wooden desk, soft natural lighting, shallow depth of field, photorealistic, 8k, highly detailed
- Negative: lowres, blurry, deformed, bad anatomy
示例 2:動漫風格
- Prompt: a girl standing in a field of lavender, sunset glow, Studio Ghibli style, anime art, vibrant colors
- Negative: lowres, bad anatomy, bad hands, text, watermark
示例 3:概念設計
- Prompt: futuristic floating city above clouds, neon lights, cyberpunk aesthetic, concept art, matte painting, ultra detailed
- Negative: lowres, grayscale, blurry, simple background
# 基礎文生圖
python3 scripts/comfyui_api.py --prompt "一隻白色小貓坐在木桌上" --width 1024 --height 1024
# 指定反向提示詞和取樣引數
python3 scripts/comfyui_api.py \
--prompt "a white kitten sitting on a wooden desk, photorealistic, 8k" \
--negative-prompt "lowres, blurry, deformed" \
--steps 25 \
--cfg-scale 7.5 \
--sampler-name euler_ancestral
# 指定模型檢查點
python3 scripts/comfyui_api.py \
--prompt "賽博朋克城市夜景" \
--checkpoint "v1-5-pruned-emaonly.safetensors"
# 指定 ComfyUI 地址
python3 scripts/comfyui_api.py \
--prompt "山水畫風格的中國古典園林" \
--comfyui-url "http://192.168.1.100:8188"
指令碼執行成功後會輸出 JSON 格式的結果,包含 image_urls 欄位,其中是生成圖片的 URL 列表。例如:
{
"status": "success",
"image_urls": [
"http://127.0.0.1:8188/view?filename=ComfyUI_00001_.png&subfolder=&type=output"
],
"prompt_id": "abc123",
"seed": 42
}
不同場景適合不同的解析度,選擇時需兼顧模型能力與生成速度:
| 場景 | 推薦解析度 | 說明 |
|---|---|---|
| 頭像/圖示 | 512x512 或 768x768 | 小尺寸生成快 |
| 手機動圖 | 768x1344 或 832x1216 | 豎屏比例 |
| 桌面桌布 | 1344x768 或 1216x832 | 橫屏比例 |
| 社交媒體 | 1024x1024 | 方圖,通用場景 |
| 高畫質大圖 | 1536x1024 或 1024x1536 | SDXL 模型推薦 |
| 問題 | 可能原因 | 解決方式 |
|---|---|---|
| 連線被拒絕 | ComfyUI 未啟動 | 啟動 ComfyUI:python main.py --listen 0.0.0.0 |
| 模型不存在 | checkpoint 名稱錯誤 | 檢查 models/checkpoints/ 目錄或省略 --checkpoint 使用當前模型 |
| 生成超時 | 步數過多或圖片過大 | 降低 --steps 或減小圖片尺寸 |
| 圖片質量差 | Prompt 不夠具體 | 參考 Prompt 編寫指南,新增風格和質量標籤 |
| 視訊記憶體不足 | 解析度太高 | 降低 width/height 或使用 --steps 15 減少計算量 |
references/ability-catalog.md這個 Skill 質量較好,文件非常詳細,對新手友好,提供了完整的引數說明和使用示例。它能穩定完成基礎的文生圖任務,指令碼功能實用。主要不足是功能較為基礎,僅支援簡單的文生圖,無法使用 ControlNet、LoRA 等進階功能。另外缺少測試用例,可能存在潛在的穩定性風險。總體而言,適合對 ComfyUI 有一定了解的使用者使用,功能擴充套件性有待提升。