Qwen千問圖像局部重繪ControlNet
使用Qwen千問Image InstantX ControlNet進行專業的區域性重繪和圖像編輯。支援物件替換、文字修改、背景更改和擴圖。
關於
Qwen-Image InstantX 局部修補 ControlNet 工作流程是用於專業圖片編輯的工具,專門處理物件替換、文字修改、背景更換以及外延補畫等任務。核心使用 Qwen-Image 模型,以高品質局部修補著稱。工作流程整合多個節點,包括 KSampler、CLIPTextEncode 與 ControlNetInpaintingAliMamaApply,以支援細緻且精準的圖片操作。
在技術流程上,先上傳所需模型與要編輯的圖片。你可以透過 LoadImage 節點開啟 MaskEditor,定義要局部修補的區域。工作流程使用 VAELoader 與 UNETLoader 進行編碼與解碼,讓編輯結果能自然融合到原始圖片中。ControlNetLoader 與 ControlNetInpaintingAliMamaApply 是套用局部修補效果的關鍵,可在維持整體一致性的同時進行細節修改。此工作流程適合需要精準調整圖片的創作者與專業設計工作者。
您提供的內容
- 正在讀取工作流程
在 ComfyUI 中執行。 此工作流程無法在此頁面上執行。請在已載入所有內容的 Comfy Cloud 中開啟,或下載到您自己的 ComfyUI。
在 Cloud 中試用工作流程內部
節點圖的唯讀預覽。請在 Comfy Cloud 中開啟,或下載後編輯節點。
從程式碼使用此工作流程
可行時會根據工作流程圖和輸入內容產生;否則會顯示儲存的範例。執行可能產生費用的程式碼前,請檢查認證資訊和端點。
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({
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 2.5,
"denoise": 1,
"latent_image": [
"122",
0
],
"model": [
"66",
0
],
"negative": [
"108",
1
],
"positive": [
"108",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 134554158057228,
"steps": 20
},
"_meta": {
"title": "KSampler"
}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"38",
0
],
"text": "The Queen, on a throne, surrounded by Knights, HD, Realistic, Octane Render, Unreal engine"
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"38",
0
],
"text": " "
},
"_meta": {
"title": "CLIP Text Encode (Negative Prompt)"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"3",
0
],
"vae": [
"39",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"37": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_fp8_e4m3fn.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"38": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"39": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"60": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"66": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"37",
0
],
"sampling": "flow",
"shift": 3.1000000000000005
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"71": {
"class_type": "LoadImage",
"inputs": {
"image": "image_qwen_image_instantx_inpainting_controlnet_input_image.png"
},
"_meta": {
"title": "Load Image"
}
},
"76": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"172",
0
],
"vae": [
"39",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"84": {
"class_type": "ControlNetLoader",
"inputs": {
"control_net_name": "Qwen-Image-InstantX-ControlNet-Inpainting.safetensors"
},
"_meta": {
"title": "Load ControlNet Model"
}
},
"108": {
"class_type": "ControlNetInpaintingAliMamaApply",
"inputs": {
"control_net": [
"84",
0
],
"end_percent": 1,
"image": [
"172",
0
],
"mask": [
"121:253",
0
],
"negative": [
"7",
0
],
"positive": [
"6",
0
],
"start_percent": 0,
"strength": 1,
"vae": [
"39",
0
]
},
"_meta": {
"title": "Apply ControlNet Inpainting (AliMama)"
}
},
"122": {
"class_type": "SetLatentNoiseMask",
"inputs": {
"mask": [
"121:253",
0
],
"samples": [
"76",
0
]
},
"_meta": {
"title": "Set Latent Noise Mask"
}
},
"124": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"121:253",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"126": {
"class_type": "ImageCompositeMasked",
"inputs": {
"destination": [
"172",
0
],
"mask": [
"121:253",
0
],
"resize_source": False,
"source": [
"8",
0
],
"x": 0,
"y": 0
},
"_meta": {
"title": "Image Composite Masked"
}
},
"163": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"126",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"172": {
"class_type": "ImageScaleToMaxDimension",
"inputs": {
"image": [
"71",
0
],
"largest_size": 1536,
"upscale_method": "area"
},
"_meta": {
"title": "Scale Image to Max Dimension"
}
},
"121:199": {
"class_type": "GrowMask",
"inputs": {
"expand": 0,
"mask": [
"71",
1
],
"tapered_corners": True
},
"_meta": {
"title": "Grow Mask"
}
},
"121:251": {
"class_type": "MaskToImage",
"inputs": {
"mask": [
"121:199",
0
]
},
"_meta": {
"title": "Convert Mask to Image"
}
},
"121:252": {
"class_type": "ImageBlur",
"inputs": {
"blur_radius": 31,
"image": [
"121:251",
0
],
"sigma": 1
},
"_meta": {
"title": "Blur Image"
}
},
"121:253": {
"class_type": "ImageToMask",
"inputs": {
"channel": "red",
"image": [
"121:252",
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)問答
可嘗試提高流程設定中的 shift 值,以減少模糊或暗部問題。
降低 shift 值可增強細節,並確保輸入圖像尺寸不要過大,以避免處理問題。
官方建議步數為 50,但實際使用約 10 步即可兼顧速度與效果。
建議圖像尺寸小於 3000 像素。可用 ImageScaleToMaxDimension 節點縮小過大圖像。
相關工作流程
- Qwen, Qwen-Image
Qwen Image 2512
- Qwen-Image
Qwen Image Edit 2509
- Qwen-Image
Qwen Image:插畫LoRA
- Qwen-Image
Qwen Image:軟糖動物LoRA
- Qwen-Image
Qwen-Image ControlNet 模型補丁
- Qwen-Image
Qwen-Image InstantX ControlNet
- Qwen-Image
Qwen-Image Union Control
- Qwen-Image
Qwen千問-圖像:文生圖
- Qwen-Image
Qwen千問-圖像:文生圖
- Qwen-Image, SeedVR2
等距柱狀投影HDR天空盒產生器