Qwen-Image InstantX Inpainting ControlNet
Professional inpainting and image editing with Qwen-Image InstantX ControlNet. Supports object replacement, text modification, background changes, and outpainting.
概要
The Qwen-Image InstantX Inpainting ControlNet workflow is a powerful tool for professional image editing, specifically designed for tasks such as object replacement, text modification, background changes, and outpainting. At its core, the workflow utilizes the Qwen-Image model, which is renowned for its high-quality inpainting capabilities. The workflow integrates several nodes, including KSampler, CLIPTextEncode, and ControlNetInpaintingAliMamaApply, to facilitate detailed and precise image manipulations.
Technically, the workflow begins with uploading the necessary models and the image to be edited. Users can then define the areas for inpainting using the MaskEditor, which is accessed via the LoadImage node. The workflow employs the VAELoader and UNETLoader nodes to encode and decode images, ensuring that the edits blend seamlessly with the original image. The ControlNetLoader and ControlNetInpaintingAliMamaApply nodes are pivotal in applying the inpainting effects, allowing for intricate modifications while maintaining the image's overall coherence.
This workflow is particularly useful for creative professionals seeking to enhance or alter images with precision and ease.
入力するもの
- ワークフローを読み込み中
ComfyUI で実行できます。 このワークフローはこのページでは実行できません。すべてが読み込まれた状態でComfy Cloudで開くか、ご自身のComfyUI用にダウンロードしてください。
Cloudで試すワークフローの内部
ノードグラフの読み取り専用プレビューです。ノードを編集するには、Comfy Cloudで開くかダウンロードしてください。
Loading the graph
Open full-size workflow preview- 作成者
- ComfyUI
カスタムノードが必要です
- ワークフローを読み込み中
コードからこのワークフローを使用する
可能な場合はワークフローグラフと入力から生成されます。それ以外の場合は保存された例が表示されます。料金が発生する場合があるため、コードを実行する前に認証情報とエンドポイントを確認してください。
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)よくある質問
Consider increasing the shift value in the workflow settings to reduce blurriness or darkness in the output.
Decrease the shift value to enhance detail, and ensure that your input image is not too large to avoid processing issues.
While the official number of steps is 50, using around 10 steps often yields satisfactory results without compromising speed.
It's recommended to use images smaller than 3000 pixels in dimension. Use the ImageScaleToMaxDimension node to resize larger images.