APNext QwenVL Z-Image Vision Cloner
Turn any image into a Z-Image-ready chat prompt — vision cloner for Z-Image
- images
- zimage_formatted
- description
- raw_json
Z-Image - Alibaba's fast 6B image model - wants its prompts in a chat format, wrapped in <|im_start|> and <|im_end|> tokens like the language-model conversations it was trained on. That's fine when you're typing a prompt yourself, and a real headache when you want to generate from a description of an existing image. This node closes that gap: it looks at your image with a local QwenVL model, writes the analysis, and formats the result as a ready-to-paste Z-Image prompt - tokens and all.
Think of it as the Vision Cloner with a Z-Image output stage bolted on. The vision part is identical in spirit - Qwen3-VL, fully local, model auto-downloaded to ComfyUI/models/LLM/Qwen-VL/ on first use, no API key. The difference is the payload it produces: zimage_formatted, which is the analysis wrapped in the chat token structure Z-Image's text encoder expects, ready to drop straight into a Z-Image node's prompt input.
How it works
The node builds its request from three template files (all in data/custom_prompts/, all overridable with inline strings):
prompt_file- the main analysis instruction (defaultzimage_vision_analysis.txt).system_prompt_file- a system-level framing prompt, on by default viainclude_system_prompt.user_mod_file- an optional user-side modification ("keep it moody and desaturated"), also driven by theuser_modificationinline field.
You get three outputs: zimage_formatted (the token-wrapped, Z-Image-ready prompt - the one you wire into a Z-Image generation node), description (the plain analysis without the wrapper, handy for reading), and raw_json (the structured raw response). The include_think_block toggle lets the model emit a thinking pass before the answer - richer analysis, slower. strip_quotes cleans stray quotes out of the formatted output so they don't corrupt the prompt, and temperature defaults lower (0.5) here than elsewhere, because Z-Image prompts should stay close to the reference rather than wander.
The inputs that matter
images- one or more reference images to analyze.qwen_model- Qwen3-VL 2B–8B (plus Thinking/FP8). 4B is a good default for style work.- The three prompt files +
include_system_prompt- the template stack; override with the inlinecustom_analysis_prompt,custom_system_promptanduser_modificationfields rather than editing files. max_tokens(default 4096),temperature,keep_model_loaded,use_flash_attention,seed/randomize_each_run- the standard QwenVL set.
Install
Pack install is the shared routine - ComfyUI Manager (search "comfyui_dagthomas") or:
cd ComfyUI/custom_nodes
git clone https://github.com/dagthomas/comfyui_dagthomas
cd comfyui_dagthomas
pip install -r requirements.txt
Restart, and let the QwenVL model download on first use. Z-Image itself is a separate model you install in ComfyUI as usual; this node only writes the prompt for it.
Common issues
- Z-Image ignores the prompt - check that
zimage_formatted, notdescription, is what you wired into the Z-Image node's prompt input; the token wrapper is the part that matters. - Prompt corrupted by quotes - turn on
strip_quotes; a stray"inside a token-wrapped prompt can break the whole thing. - Slow or memory-heavy - a thinking-pass 8B model is the expensive combo. Drop to 4B Instruct (or an FP8 build) and turn
include_think_blockoff unless you need the deeper analysis. - Custom templates not in the dropdown - the prompt-file lists are read at startup; add
.txtfiles todata/custom_prompts/and restart ComfyUI.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| qwen_model | COMBO | Qwen3-VL-2B-Instruct | 23 options: Qwen3-VL-2B-Instruct, Qwen3-VL-2B-Thinking, Qwen3-VL-2B-Instruct-FP8, Qwen3-VL-2B-Thinking-FP8, Qwen3-VL-4B-Instruct, Qwen3-VL-4B-Thinking, +17 |
| prompt_file | COMBO | zimage_vision_analysis.txt | 44 options: (none), cloner.txt, cloner_concept_blender.txt, extractor.txt, follow.txt, gemini.txt, +38 |
| system_prompt_file | COMBO | zimage_vision_system.txt | 44 options: (none), cloner.txt, cloner_concept_blender.txt, extractor.txt, follow.txt, gemini.txt, +38 |
| user_mod_file | COMBO | zimage_vision_user_mod.txt | 44 options: (none), cloner.txt, cloner_concept_blender.txt, extractor.txt, follow.txt, gemini.txt, +38 |
| max_tokens | INT | 4096512–8192 | — |
| temperature | FLOAT | 0.500.1–1 | — |
| keep_model_loaded | BOOLEAN | true | — |
| use_flash_attention | BOOLEAN | false | — |
| include_system_prompt | BOOLEAN | true | — |
| include_think_block | BOOLEAN | false | — |
| strip_quotes | BOOLEAN | false | — |
| seed | INT | -1-1–18446744073709550000 | — |
| randomize_each_run | BOOLEAN | true | — |
| custom_analysis_promptopt | STRING | — | |
| user_modificationopt | STRING | — | |
| custom_system_promptopt | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| zimage_formatted | STRING | — |
| description | STRING | — |
| raw_json | STRING | — |