2.2 Creator - 擴散引導
Learn how to guide diffusion for precise image editing with inpainting and controlnet using Z Image Turbo.
關於
「2.2 Creator - 擴散引導」工作流程於 ComfyUI 中,透過結合修補與 ControlNet 技術,提升圖像編輯精度。核心為 Z Image Turbo 模型,能高效且精確地進行擴散處理。流程包含 CLIPLoader、VAELoader 等節點負責圖像載入與處理,並以 DifferentialDiffusion、InpaintModelConditioning 等節點,針對空間變化引導擴散,無需重新訓練模型即可進行細緻編輯。
流程運用 ControlNet 提供結構引導,如邊緣偵測或深度圖,確保擴散過程遵循結構特徵。這透過 ZImageFunControlnet 與 Controlnet Preprocessor 節點實現。利用每像素「強度」圖,流程可平滑且漸進地變化,特別適合需高精度與控制的應用,例如修補特定區域並維持周圍內容完整。
您提供的內容
- 正在讀取工作流程
在 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({
"92": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_3_4b.safetensors",
"device": "default",
"type": "lumina2"
},
"_meta": {
"title": "Load CLIP"
}
},
"93": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"94": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"112",
0
],
"vae": [
"93",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"95": {
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"99",
0
]
},
"_meta": {
"title": "Conditioning Zero Out"
}
},
"96": {
"class_type": "DifferentialDiffusion",
"inputs": {
"model": [
"98",
0
],
"strength": 1
},
"_meta": {
"title": "Differential Diffusion"
}
},
"98": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"109",
0
],
"sampling": "flow",
"shift": 3
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"99": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"92",
0
],
"text": "sunglasses."
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"100": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Z-Image-Turbo",
"images": [
"94",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"101": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "z_image_turbo_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"103": {
"class_type": "ModelPatchLoader",
"inputs": {
"name": "Z-Image-Turbo-Fun-Controlnet-Union-2.1.safetensors"
},
"_meta": {
"title": "Load Model Patch"
}
},
"105": {
"class_type": "InpaintModelConditioning",
"inputs": {
"mask": [
"108:184",
0
],
"negative": [
"95",
0
],
"noise_mask": True,
"pixels": [
"108:181",
0
],
"positive": [
"99",
0
],
"vae": [
"93",
0
]
},
"_meta": {
"title": "InpaintModelConditioning"
}
},
"106": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"108:184",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"107": {
"class_type": "LoadImage",
"inputs": {
"image": "gsc_creator_2_2_input.png"
},
"_meta": {
"title": "Load Image"
}
},
"109": {
"class_type": "ZImageFunControlnet",
"inputs": {
"end_percent": 1,
"image": [
"108:181",
0
],
"inpaint_image": [
"108:181",
0
],
"mask": [
"108:184",
0
],
"model": [
"101",
0
],
"model_patch": [
"103",
0
],
"start_percent": 0,
"strength": 1,
"vae": [
"93",
0
]
},
"_meta": {
"title": "Apply Fun ControlNet"
}
},
"112": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"105",
2
],
"model": [
"96",
0
],
"negative": [
"105",
1
],
"positive": [
"105",
0
],
"sampler_name": "res_multistep",
"scheduler": "simple",
"seed": 467616719697168,
"steps": 9
},
"_meta": {
"title": "KSampler"
}
},
"122": {
"class_type": "ImageStitch",
"inputs": {
"direction": "down",
"image1": [
"107",
0
],
"image2": [
"94",
0
],
"match_image_size": True,
"spacing_color": "white",
"spacing_width": 0
},
"_meta": {
"title": "Stitch Images"
}
},
"123": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"122",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"108:181": {
"class_type": "ImageResize+",
"inputs": {
"condition": "always",
"height": 1024,
"image": [
"107",
0
],
"interpolation": "lanczos",
"method": "keep proportion",
"multiple_of": 0,
"width": 1024
},
"_meta": {
"title": "🔧 Image Resize"
}
},
"108:182": {
"class_type": "ImageResize+",
"inputs": {
"condition": "always",
"height": 1024,
"image": [
"108:183",
0
],
"interpolation": "lanczos",
"method": "keep proportion",
"multiple_of": 0,
"width": 1024
},
"_meta": {
"title": "🔧 Image Resize"
}
},
"108:183": {
"class_type": "MaskToImage",
"inputs": {
"mask": [
"107",
1
]
},
"_meta": {
"title": "Convert Mask to Image"
}
},
"108:184": {
"class_type": "ImageToMask",
"inputs": {
"channel": "red",
"image": [
"108:182",
0
]
},
"_meta": {
"title": "Convert Image to Mask"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)問答
ControlNet 以邊緣或深度圖等特徵,為擴散過程提供結構引導,確保編輯結果符合預期結構。
Differential Diffusion 利用每像素「強度」圖,實現平滑、漸進且空間變化的修補,無需重新訓練模型即可精確編輯。
本流程以單張圖像編輯為主,若需批次處理,可自動化圖像載入與遮罩建立步驟。
建議 KSampler 去雜訊參數設於 0.5 至 1.0,ModelSampling shift 設於 3.0 至 10.0,依所需細節與平滑度調整。
相關工作流程
- ZZ-Image-Turbo
1.1 入門-文字轉圖像
- ZZ-Image-Turbo
2.1 Creator-擴散基礎
- ZZ-Image-Turbo
2.3 Creator:影像放大與分析
- Wan2.2, Z-Image-Turbo
AIrt MAchIne
- Google Gemini, Kling 3.0, Z-Image-Turbo
AIrt MAchIne(API 版本)
- ZZ-Image-Turbo
Z-Image-Turbo 控制生圖
- ZZ-Image-Turbo
Z-Image-Turbo: 文生圖
- ZZ-Image-Turbo
Z-Image-Turbo_Oldschool-Hud-Graphics
- ZZ-Image-Turbo
切換節點
- ZZ-Image-Turbo
圖像放大:Z-Image-Turbo 2K
- Kling 2.6, Nano Banana Pro, Z-Image-Turbo
圖生影片
- ZZ-Image-Turbo
從列表批次處理文字提示