Z-Image-Turbo 控制生圖
支援Canny、HED、深度、姿態和MLSD的多控制ControlNet,適用於Z-Image-Turbo。
工作流程內部
來源範本的唯讀預覽。請在 Cloud 中開啟,以探索節點並進行變更。
從您的程式碼呼叫此模型
以下請求使用與 Playground 相同的已準備節點圖和設定。每次提交都可能啟動付費執行;若提交結果不明,請勿自動重試提交。
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
- 您的檔案
- 由程式碼透過其 URL 上傳
需要付費 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": "z-image-turbo",
"images": [
"70:43",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"56": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"57",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"57": {
"class_type": "Canny",
"inputs": {
"high_threshold": 0.32,
"image": [
"58",
0
],
"low_threshold": 0.1
},
"_meta": {
"title": "Detect Edges (Canny)"
}
},
"58": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"70:39": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_3_4b.safetensors",
"device": "default",
"type": "lumina2"
},
"_meta": {
"title": "Load CLIP"
}
},
"70:40": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"70:41": {
"class_type": "EmptySD3LatentImage",
"inputs": {
"batch_size": 1,
"height": [
"70:69",
1
],
"width": [
"70:69",
0
]
},
"_meta": {
"title": "EmptySD3LatentImage"
}
},
"70:42": {
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"70:45",
0
]
},
"_meta": {
"title": "Conditioning Zero Out"
}
},
"70:43": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"70:44",
0
],
"vae": [
"70:40",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"70:44": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"70:41",
0
],
"model": [
"70:47",
0
],
"negative": [
"70:42",
0
],
"positive": [
"70:45",
0
],
"sampler_name": "res_multistep",
"scheduler": "simple",
"seed": 582911328872997,
"steps": 9
},
"_meta": {
"title": "KSampler"
}
},
"70:45": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"70:39",
0
],
"text": "Realistic photo of a moonlit greenhouse library at night, built inside the same room layout. The ceiling slats become dark walnut beams strung with tiny warm bulbs, and the tall window wall turns into old greenhouse glass fogged with condensation, tropical leaves pressing against it from outside. The low sofa is upholstered in deep emerald velvet, the stone coffee table becomes a slab of black marble stacked with open books, and the lounge chair is worn burgundy leather. The shelving grid on the right holds trailing ferns and small brass lanterns. Cool blue moonlight falls through the glass, warm lamplight pools on the terrazzo floor, quiet and cosy, light film grain."
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"70:46": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "z_image_turbo_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"70:47": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"70:60",
0
],
"sampling": "flow",
"shift": 3
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"70:60": {
"class_type": "QwenImageDiffsynthControlnet",
"inputs": {
"end_percent": 1,
"image": [
"57",
0
],
"model": [
"70:46",
0
],
"model_patch": [
"70:64",
0
],
"start_percent": 0,
"strength": 1,
"vae": [
"70:40",
0
]
},
"_meta": {
"title": "Apply Qwen Image DiffSynth ControlNet"
}
},
"70:64": {
"class_type": "ModelPatchLoader",
"inputs": {
"name": "Z-Image-Turbo-Fun-Controlnet-Union.safetensors"
},
"_meta": {
"title": "Load Model Patch"
}
},
"70:69": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"57",
0
]
},
"_meta": {
"title": "Get Image Size"
}
}
})
workflow.set_input("58", "image", client.assets.from_url("https://comfy.org/catalog-media/d582dae6-4b4a-4ef9-9a66-ce170401a12d/6ac33887-7efb-472b-b4bf-e29fa62ab9d3"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("9"):
output.to_file(output.name)試試範例
關於此工作流程
「Z-Image-Turbo Fun Union ControlNet」工作流程是一套進階的圖像生成流程,結合多個 ControlNet 模型,能精確強化與操控圖像。此流程整合多種圖像前處理技術,包括 Canny 邊緣偵測、HED(全域嵌套邊緣偵測)、深度估算、姿勢辨識與 MLSD(多線段偵測)。這些技術協同運作,細緻調控 Z-Image-Turbo 模型的輸出,實現細膩且具層次的圖像轉換。透過 SaveImage、MarkdownNote、PreviewImage 及 ImageScaleToMaxDimension 等節點,流程確保圖像處理高效且精準。
技術上,此流程最大特色是能同時處理多種控制輸入,讓使用者對圖像生成過程有高度掌控。多種 ControlNet 模型的整合,讓使用者可針對輸入圖像套用不同前處理技術,並依需求縮放與轉換,滿足各種輸出規格。此流程特別適合需要精細圖像操控的應用,如數位藝術創作、擴增實境、進階照片編輯等。
問答
多個 ControlNet 模型可同時套用不同強化與控制,讓圖像操控更靈活且精細。
由於流程較複雜,處理時間較長,不建議用於即時應用,較適合重視品質與精度的專案。
可透過 ImageScaleToMaxDimension 節點設定輸出圖像的最大尺寸。
由於流程較複雜且需理解多個 ControlNet 模型,對初學者有挑戰,但對想學習進階圖像處理技術者是很好的學習機會。