Flux.1 Canny 模型
使用Flux Canny邊緣檢測引導產生圖像。
下載工作流程在 Cloud 中試用 API 文件
關於
ComfyUI 的 Flux.1 Canny 邊緣模型工作流程,結合 Flux.1 模型與邊緣偵測技術,提升圖像生成的結構控制。流程運用 Canny 邊緣偵測法,確保產生的圖像能緊貼輸入圖像的結構輪廓。流程包含 Canny 節點進行邊緣偵測,FluxGuidance 節點則將這些邊緣資訊整合進圖像生成過程。透過這些節點,用戶可獲得更可控且精確的圖像輸出,特別適合需要保留特定結構細節的任務。
流程從載入 Flux.1 與 CLIPTextEncode 等必要模型開始,KSampler 節點根據偵測到的邊緣與文字提示進行圖像取樣。VAEDecode 節點將潛在空間解碼為可見圖像,最後用 SaveImage 儲存。此流程特別適合藝術家與設計師在創作時,兼顧創意與結構精度。
您提供的內容
- 正在讀取工作流程
在 ComfyUI 中執行。 此工作流程無法在此頁面上執行。請在已載入所有內容的 Comfy Cloud 中開啟,或下載到您自己的 ComfyUI。
在 Cloud 中試用範例
工作流程內部
節點圖的唯讀預覽。請在 Comfy Cloud 中開啟,或下載後編輯節點。
Loading the graph
Open full-size workflow preview需要自訂節點
- 正在讀取工作流程
從程式碼使用此工作流程
可行時會根據工作流程圖和輸入內容產生;否則會顯示儲存的範例。執行可能產生費用的程式碼前,請檢查認證資訊和端點。
1 取得 API 金鑰 ↗
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
需要付費 Cloud 方案與點數。
下載 API JSONAPI 文件 ↗
# 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({
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"35",
2
],
"model": [
"31",
0
],
"negative": [
"35",
1
],
"positive": [
"35",
0
],
"sampler_name": "euler",
"scheduler": "normal",
"seed": 1125476660951871,
"steps": 20
},
"_meta": {
"title": "KSampler"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"3",
0
],
"vae": [
"32",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"17": {
"class_type": "LoadImage",
"inputs": {
"image": "flux_canny_model_example_input_image.png"
},
"_meta": {
"title": "Load Image"
}
},
"18": {
"class_type": "Canny",
"inputs": {
"high_threshold": 0.3,
"image": [
"17",
0
],
"low_threshold": 0.15
},
"_meta": {
"title": "Detect Edges (Canny)"
}
},
"19": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"18",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"23": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"34",
0
],
"text": "A vibrant red ladybug rests on a blooming deep purple rose with lush, velvety petals. The background is a soft pink, filled with subtly blurred roses of the same pink shade, creating a dreamy and romantic atmosphere."
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"26": {
"class_type": "FluxGuidance",
"inputs": {
"conditioning": [
"23",
0
],
"guidance": 30
},
"_meta": {
"title": "FluxGuidance"
}
},
"31": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "flux1-canny-dev.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"32": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"34": {
"class_type": "DualCLIPLoader",
"inputs": {
"clip_name1": "clip_l.safetensors",
"clip_name2": "t5xxl_fp16.safetensors",
"device": "default",
"type": "flux"
},
"_meta": {
"title": "Load CLIP (Dual)"
}
},
"35": {
"class_type": "InstructPixToPixConditioning",
"inputs": {
"negative": [
"37",
0
],
"pixels": [
"18",
0
],
"positive": [
"26",
0
],
"vae": [
"32",
0
]
},
"_meta": {
"title": "InstructPixToPixConditioning"
}
},
"37": {
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"23",
0
]
},
"_meta": {
"title": "Conditioning Zero Out"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)問答
Canny 節點負責偵測上傳圖像的邊緣,作為圖像生成的結構引導。
雖然可以,但本流程更適合需要保留特定輪廓或結構的情境。
邊緣清晰、輪廓明確的圖像最適合,因為 Canny 節點依賴邊緣偵測來引導生成。
FluxGuidance 節點將偵測到的邊緣整合進圖像生成過程,確保最終輸出能貼合結構引導。