OmniGen2圖像編輯
使用OmniGen2的高階圖像編輯功能和文字渲染支援,透過自然語言指令編輯圖像。
關於
OmniGen2 圖像編輯工作流程,專為利用自然語言指令增強與轉換圖片而設計。結合強大的 OmniGen 模型,讓使用者能輕鬆進行如材質變換、光影效果等複雜編輯。流程包含 CLIPTextEncode(解讀文字提示)、VAEDecode(生成最終圖片)、SaveImage(輸出結果)等關鍵節點。透過 ImageScaleToTotalPixels 與 RandomNoise 等節點,確保圖片轉換既精確又具創意。
技術上,流程會先載入必要模型並準備圖片。CLIPLoader 與 UNETLoader 節點負責圖片資料載入與處理,DualCFGGuider 與 SamplerCustomAdvanced 節點則提供進階取樣控制。此流程特別適合藝術家與設計師快速反覆試驗圖像概念,或任何需要精細圖片編輯但不想手動繁瑣操作的使用者。
您提供的內容
- 正在讀取工作流程
在 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({
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"10",
0
],
"text": "Transform character into crystal material, transparent crystal texture, sparkling surface, prismatic light effects, magical appearance, elegant translucent look"
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"10",
0
],
"text": "deformed, blurry, over saturation, bad anatomy, disfigured, poorly drawn face, mutation, mutated, extra_limb, ugly, poorly drawn hands, fused fingers, messy drawing, broken legs censor, censored, censor_bar"
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"28",
0
],
"vae": [
"13",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"10": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_fp16.safetensors",
"device": "default",
"type": "omnigen2"
},
"_meta": {
"title": "Load CLIP"
}
},
"11": {
"class_type": "EmptySD3LatentImage",
"inputs": {
"batch_size": 1,
"height": [
"32",
1
],
"width": [
"32",
0
]
},
"_meta": {
"title": "EmptySD3LatentImage"
}
},
"12": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "omnigen2_fp16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"13": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"14": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"17",
0
],
"vae": [
"13",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"15": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"6",
0
],
"latent": [
"14",
0
]
},
"_meta": {
"title": "Set Reference Latent"
}
},
"16": {
"class_type": "LoadImage",
"inputs": {
"image": "image_omnigen2_image_edit_input_image.png"
},
"_meta": {
"title": "Load Image"
}
},
"17": {
"class_type": "ImageScaleToTotalPixels",
"inputs": {
"image": [
"16",
0
],
"megapixels": 1,
"resolution_steps": 1,
"upscale_method": "area"
},
"_meta": {
"title": "Scale Image to Total Pixels"
}
},
"20": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"21": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 441693270797774
},
"_meta": {
"title": "RandomNoise"
}
},
"23": {
"class_type": "BasicScheduler",
"inputs": {
"denoise": 1,
"model": [
"12",
0
],
"scheduler": "simple",
"steps": 20
},
"_meta": {
"title": "BasicScheduler"
}
},
"27": {
"class_type": "DualCFGGuider",
"inputs": {
"cfg_cond2_negative": 2,
"cfg_conds": 5,
"cond1": [
"15",
0
],
"cond2": [
"29",
0
],
"model": [
"12",
0
],
"negative": [
"7",
0
],
"style": "regular"
},
"_meta": {
"title": "Dual CFG Guider"
}
},
"28": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"27",
0
],
"latent_image": [
"11",
0
],
"noise": [
"21",
0
],
"sampler": [
"20",
0
],
"sigmas": [
"23",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"29": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"7",
0
],
"latent": [
"14",
0
]
},
"_meta": {
"title": "Set Reference Latent"
}
},
"32": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"17",
0
]
},
"_meta": {
"title": "Get Image Size"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)問答
可用自然語言提示進行材質變換、光影效果、材質調整等多種編輯。
按 Ctrl + B,將所有 Bypass 模式節點切換為正常模式,即可啟用第二張圖片輸入。
可以,刪除 Get Image Size 節點後即可調整相關參數自訂尺寸。
需要 OmniGen、CLIP、VAE 與 UNET 模型,才能完整發揮本流程功能。