OmniGen2: 文生圖
使用OmniGen2統一的7B多模態模型和雙路徑架構從文字提示產生高品質圖像。
關於
此工作流程示範一條最精簡、快速的路徑:用 OmniGen2 的統一 7B 多模態模型,從文字提示詞直接產出完成圖像。單一 OmniGen2 節點(自訂節點 id 4b17d220-4312-4981-9eae-9a76bf3b6ec9)會接收提示詞,使用 Qwen2.5-VL 文字編碼器進行編碼,並在不需要擴散取樣器或冗長節點鏈的情況下生成高品質圖像。輸出會送到 SaveImage 以進行一致的檔名與匯出;同時提供 MarkdownNote 作為畫布內指引並連到官方文件。
在技術上,提示詞會透過 qwen_2.5_vl_fp16.safetensors 文字編碼器嵌入,並進入 OmniGen2 的雙路徑架構,在單一模型中整合語言理解與圖像生成。該節點提供實用控制項(例如解析度、seed、batch/count),方便調整長寬比與可重現性。整套設定也可包成 Subgraph,讓 UI 更乾淨:需要時再展開以顯示進階參數並調整預設值。這讓工作流程適合快速迭代、輸出可預期,也便於交接給團隊成員。
您提供的內容
- 正在讀取工作流程
在 ComfyUI 中執行。 此工作流程無法在此頁面上執行。請在已載入所有內容的 Comfy Cloud 中開啟,或下載到您自己的 ComfyUI。
在 Cloud 中試用工作流程內部
節點圖的唯讀預覽。請在 Comfy Cloud 中開啟,或下載後編輯節點。
Loading the graph
Open full-size workflow preview需要自訂節點
- 正在讀取工作流程
從程式碼使用此工作流程
可行時會根據工作流程圖和輸入內容產生;否則會顯示儲存的範例。執行可能產生費用的程式碼前,請檢查認證資訊和端點。
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
需要付費 Cloud 方案與點數。
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"42:8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"42:10": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_fp16.safetensors",
"device": "default",
"type": "omnigen2"
},
"_meta": {
"title": "Load CLIP"
}
},
"42:11": {
"class_type": "EmptySD3LatentImage",
"inputs": {
"batch_size": 1,
"height": 1024,
"width": 1024
},
"_meta": {
"title": "EmptySD3LatentImage"
}
},
"42:12": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "omnigen2_fp16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"42:13": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"42:20": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"42:21": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 375248071721913
},
"_meta": {
"title": "RandomNoise"
}
},
"42:23": {
"class_type": "BasicScheduler",
"inputs": {
"denoise": 1,
"model": [
"42:12",
0
],
"scheduler": "simple",
"steps": 20
},
"_meta": {
"title": "BasicScheduler"
}
},
"42:27": {
"class_type": "DualCFGGuider",
"inputs": {
"cfg_cond2_negative": 2,
"cfg_conds": 5,
"cond1": [
"42:6",
0
],
"cond2": [
"42:7",
0
],
"model": [
"42:12",
0
],
"negative": [
"42:7",
0
],
"style": "regular"
},
"_meta": {
"title": "Dual CFG Guider"
}
},
"42:28": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"42:27",
0
],
"latent_image": [
"42:11",
0
],
"noise": [
"42:21",
0
],
"sampler": [
"42:20",
0
],
"sigmas": [
"42:23",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"42:6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"42:10",
0
],
"text": "A cat with a crown lounging on a velvet throne, royal atmosphere, luxurious fabric texture, regal pose, detailed fur, ornate crown, dramatic lighting"
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"42:7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"42:10",
0
],
"text": "blurry, low quality, distorted, ugly, bad anatomy, deformed, poorly drawn"
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"42:8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"42:28",
0
],
"vae": [
"42:13",
0
]
},
"_meta": {
"title": "VAE Decode"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)問答
把 qwen_2.5_vl_fp16.safetensors 放在 ComfyUI/models/text_encoders。若使用 Hugging Face 上重新封裝的 OmniGen2 權重,請完全依照其資料夾結構與命名。
在 OmniGen2 節點設定 width 與 height。常見組合有 1024x1024(正方形)、1344x768(16:9)、或 832x1216(2:3)。解析度越高越吃 VRAM,建議逐步增加。
在 OmniGen2 節點使用固定 seed。若要探索變化,可以微調 seed,或啟用 batch/count 一次生成多張輸出。
如果你的 OmniGen2 節點提供 negative_prompt 輸入,就用它來避開不想要的元素;若沒有,請把限制直接寫進提示詞(例如「no text, minimal background, without watermark」)。