🐋 千问图像集成采样器——Github:@luguoli
The Qwen-Image sampler that eats your wire spaghetti
- model
- clip
- vae
- image1
- image2
- image3
- image4
- image5
- latent
- controlnet_data
- 生成图像Image
- (可选)Latent
- 缩放后原图Scaled Image
If you've ever built a Qwen-Image or Z-Image workflow the "official" way, you know the feeling: a prompt encoder, an AuraFlow shift node, a CFG normalization node, a latent creator, a KSampler, a VAE decode, plus scaling and cleanup nodes, all draped in a dozen wires. This node is that entire pipeline collapsed into one box. Load your model, clip and VAE, type a prompt, and it does prompt encoding, sampling, decoding, optional auto-save, even VRAM cleanup - and it's exactly how people actually run Qwen and Z-Image these days. The community recommendation for a Z-Image depth workflow was literally "use this, two or three nodes is enough."
It's the flagship of luguoli's pack (the whale 🐋, "千问图像集成采样器"), and it does double duty: text-to-image and image-to-image in a single node, including Qwen-Image-Edit-style instruction editing with up to five reference images.
How it works
Pick generation_mode. In text-to-image it just tokenizes your prompt and makes an empty latent at the width/height you set. In image-to-image the interesting stuff happens: each reference image is encoded twice at once - once into the vision-language encoder as 384×384 image tokens, and once into the VAE at the image's strict original resolution (rounded to a multiple of 8). That dual-encode is the whole Qwen-Edit design. And the "strict original resolution" part is the point of this node: the official TextEncodeQwenImageEditPlus used to upscale your reference, which is where the infamous offset/shrink artifacts came from. This keeps the latent true to the input, and the pack's own code comment says exactly that - it exists to solve the offset problem while keeping the official node's instruction-following.
Before sampling it can also apply two tweaks. auraflow_shift (default 3.0) patches a flow-sampling shift onto the model - the AuraFlow technique for balancing schedule shape, speed and quality. cfg_norm_strength (default 1.0) installs a post-CFG normalization that stops high guidance from oversaturating. Both only engage when set above zero, so 0 turns them off. If you've wired in controlnet_data from the companion loader, each condition gets applied here, with repaint masks scaled to match your target size.
Inputs that matter
generation_mode- text-to-image or image-to-image.width/height- required for text-to-image (it throws otherwise). For image-to-image, setting them letterboxes your references to that size while keeping aspect ratio; 0 means no scaling.image1–image5- the references, up to five, image1 being the main one. No image1 in image-to-image mode and it refuses to run.denoise- lower it in image-to-image to keep more of the original.steps(default 4),cfg(default 1.0),sampler_name,scheduler- the usual suspects. Qwen is LLM-encoded and prompt it in sentences, not tags; it's happy in the 4–20 step range, and pushing CFG much past ~7 burns the image.batch_size- 1–10. Start at 1 and watch your VRAM.auto_save_output_folder- set a path (absolute, or relative to ComfyUI's output dir) and every result saves asprefix_seed_00000.png. Leave blank to disable.
Three outputs: the generated Image, the Latent (handy if you want to chain a refiner without a decode/encode round trip), and the Scaled Image - a preview of what the sampler actually saw, which saves you an "oh no, it upscaled my reference" moment.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/luguoli/ComfyUI-Qwen-Image-Integrated-KSampler.git
pip install -r requirements.txt
Then restart ComfyUI. Or ComfyUI Manager → search "ComfyUI-Qwen-Image-Integrated-KSampler" → Install. The requirements are all standard (torch, transformers, einops, psutil) and the repo ships no weights. The real dependency is the model: Qwen-Image is a 20B MMDiT and a VRAM hog, so quantization is basically deployment, not an option - GGUF, fp8, or Nunchaku SVDQuant on consumer cards. This node also handles Z-Image fine, and that one runs on a 6GB card.
Gotchas
Text-to-image without width/height errors out on purpose, and image-to-image without image1 does too - both messages are bilingual and clear. The sound notification is Windows-only (winsound), so don't expect a chime on Linux. The "clean CPU memory after finish" option is aggressive: it flushes file cache, processes and dynamic libraries, so enable it only when a long session is leaking. And if you want the Chinese UI, the post-ComfyUI-0.3.68 localization break means you'll need to run the pack's 自动汉化节点.bat and install ComfyUI-DD-Translation. That's a lot of Chinese characters for one node - but then, the node itself just saved you about seven wires.
Inputs (30)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | 🤖 Model - 扩散模型输入,用作图像生成的核心模型 | |
| clip | CLIP | 🟡 Clip - CLIP模型,用于文本编码和条件生成 | |
| vae | VAE | 🎨 Vae - VAE模型输入,用于将潜空间解码为最终可见图像 | |
| positive_prompt | STRING | ✅ 正向提示 - 描述期望图像元索的文本提示 | |
| negative_prompt | STRING | ❌ 负向提示 - 描述要避免的图像元素的文本提示 | |
| generation_mode | COMBO | 🎨 生成模式 - 选择文生图或图生图模式 | |
| batch_size | INT | 11–10 | 📦 批次数量 - 生成图像的数量 |
| width | INT | 00–16384 | 📐 宽度(文生图-必填,图生图-填写缩放/填0不缩放) |
| height | INT | 00–16384 | 📏 高度(文生图-必填,图生图-填写缩放/填0不缩放) |
| seed | INT | 00–18446744073709550000 | 🎲 生成噪波的随机种。 |
| steps | INT | 41–10000 | 📊 降噪的步数。 |
| cfg | FLOAT | 1.00–100 | 🎛️ 用于平衡随机性和提示词服从性。提高该值会使结果更加符合提示词,但过高会导致图像质量下降。 |
| sampler_name | COMBO | euler | 🌀 采样算法,会影响结果质量、生成速度、风格样式。 |
| scheduler | COMBO | simple | 📈 控制逐渐移除噪波的方法。 |
| denoise | FLOAT | 1.000–1 | 🔄 降噪的强度,降低该值会保留原图的大部分内容从而实现图生图。 |
| image1opt | IMAGE | 🖼️ 图像1(主图) - 参考图像1(主图),用于条件生成和潜空间编码。如果不传入,则文生图。 | |
| image2opt | IMAGE | 🖼️ 图像2 - 参考图像2,用于条件生成和潜空间编码 | |
| image3opt | IMAGE | 🖼️ 图像3 - 参考图像3,用于条件生成和潜空间编码 | |
| image4opt | IMAGE | 🖼️ 图像4 - 参考图像4,用于条件生成和潜空间编码 | |
| image5opt | IMAGE | 🖼️ 图像5 - 参考图像5,用于条件生成和潜空间编码 | |
| latentopt | LATENT | 🟣 Latent - 文生图、图生图(传入了主图)可不传,自动创建,如需使用ControlNet等可自行传入 | |
| controlnet_dataopt | CONTROL_NET_DATA | 🌿 ControlNet 数据(可选) - 输入 ControlNet 集成加载器输出的数据包,直接应用 ControlNet 控制 | |
| auraflow_shiftopt | FLOAT | 3.000–100 | ⚡ 采样算法AuraFlow移位 - 采样算法(AuraFlow) 移位Shift参数,影响速度和质量 (0-100) |
| cfg_norm_strengthopt | FLOAT | 1.000–100 | ⚖️ CFGNorm 强度 - CFG标准化强度,动态调整CFG指导强度 (0-100) |
| enable_clean_gpu_memoryopt | BOOLEAN | false | 🗑️ 清理显存占用 - 在采样/解码前后清理显存占用,以释放资源给其他应用 |
| enable_clean_cpu_memory_after_finishopt | BOOLEAN | false | 🗑️ 完成后清理内存 - 生成完成后清理CPU内存 |
| enable_sound_notificationopt | BOOLEAN | false | 🔊 完成后播放声音 - 解码完成后播放通知声音以提醒用户 |
| auto_save_output_folderopt | STRING | 📁 自动保存输出文件夹(留空不自动保存) - 留空则不执行保存 | |
| output_filename_prefixopt | STRING | auto_save | 📝 输出文件名前缀 - 默认auto_save |
| instructionopt | STRING | Describe the key features of the input image (color, shape, size, texture, objects, background), then explain how the user's text instruction should alter or modify the image. Generate a new image that meets the user's requirements while maintaining consistency with the original input where appropriate. | 📝 指令 - 系统指令,用于指导参考图像的图像编辑 |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| 生成图像Image | IMAGE | — |
| (可选)Latent | LATENT | — |
| 缩放后原图Scaled Image | IMAGE | — |