🧳Qwen-image2.1提示词优化@炮老师的小课堂
A local rewriter that enforces the rules
- 🤖本地模型
- 🖼️参考图1
- 🖼️参考图2
- 🖼️参考图3
- 🖼️参考图4
- 🖼️参考图5
- 🖼️参考图6
- 🖼️参考图7
- 🖼️参考图8
- 📋可用提示词
- 📐wh_ratio
- 🖼️ratio_follow
- 🧾JSON结果
- 🧩展示结果
Why a prompt rewriter earns its slot
Qwen-Image renders text properly, and it has opinions about how you talk to it. The house style is not tags and not instructions - it's an observation: one long English paragraph describing the finished frame as if you were standing in front of it, medium and style and subject and palette, then an inventory of objects with positions. No "make it", no "4K, sharp", no ratio, no pixel counts. Literal text you want rendered gets copied character for character, in its own script, inside quotes.
People get this wrong constantly, in ways that are invisible until the glyphs come back misspelled or the aspect ratio is ignored. DapaoQwenImage21Prompt (🧳Qwen-image2.1提示词优化@炮老师的小课堂) rewrites for you and enforces the rules, on a local GGUF vision model instead of an API key. Its rule files are unmodified copies of the iamyoki/qwen-image-2.1-skill references (Apache-2.0, credited). One honest caveat: that ruleset is new and barely discussed in English, so treat it as "the current documented Qwen-Image-2.x prompt spec" rather than something with a track record. The 20B base and Edit line it belongs to are covered in our Qwen panels.
How it works
It turns a chat-based skill into ComfyUI widgets with machine-readable outputs, which is the whole trick. Your request - plus 上游需求 if you piped one in, external text first - becomes directives; the node prepends the reference rules as a system prompt and demands exactly one JSON object back with rewritten_prompt, wh_ratio, ratio_follow, optimization_breakdown and tweak_suggestions.
Then it validates before you see anything. JSON is recovered tolerantly: <think> blocks and code fences stripped, first decodable object scanned out. The prompt must be non-empty, newlines collapsed, whitespace squashed - Qwen wants one paragraph. wh_ratio must literally match \d+:\d+. ratio_follow must be an <imageN> label, with N no larger than your image count. In edit mode with two or more images, the prompt must mention every <imageN>; miss one and the node errors and names it.
Images are downscaled to a 1536px max edge and sent as base64 JPEG. Defaults are temperature 0.35, top_p 0.9, 2048 output tokens. Nine task modes collapse to two internal rule sets - t2i and edit - and 自动识别 picks t2i with no images connected, edit otherwise. Guards are strict: t2i with images connected errors, edit with zero images errors, 继承基准图 in t2i errors.
Inputs worth setting
- 🤖本地模型 - the pack's
DAPAO_LOCAL_MODEL, so you also need the 🤖大炮本地模型加载器 node in the graph. With any images connected, that loader must have a matching mmproj; this node checks and tells you. - 📝原始需求 and, when chaining, 🔗上游需求 - a forced-input STRING, joined before your own text.
- 🧭任务模式 - 自动识别 by default; 文生图, or one of the edit-flavoured modes (图像编辑与局部修改, 多图合成, 风格迁移, 背景替换, 换脸或换装, 扩图, 参考主体生成新场景).
- 📐输出画幅 - 23 choices.
自动判断lets the model infer,继承基准图follows the base image, or pin one like3:2,21:9,18:39. - 🖼️基准图 (1–8) - which connected image keeps its canvas in a multi-image edit. Numbering follows connection order, so connect deliberately.
- 🔤画面文字 + ✍️自定义准确文字 - the text policy.
自定义准确文字forces the literal string, character for character, in straight double quotes, and makes the custom field mandatory. - 🧩输出样式 - 标准展示 / 仅提示词 / 严格JSON. Display only; the prompt output stays pure either way.
- 📤最大输出token (2048), 🌡️温度 (0.35), 🎲随机种子, 🧹为生图释放显存 (default on).
- 🖼️参考图1–8 - each slot takes exactly one image; a batch raises an error telling you to split it first.
Outputs
📋可用提示词 is the one you wire - always plain prompt text, never decorated, so it drops straight into your Qwen-Image text encode. 📐wh_ratio ("3:2") and 🖼️ratio_follow ("<image1>", or empty) carry the canvas decision as strings for whatever node accepts a ratio; if yours takes width and height, read them and set the latent yourself. 🧾JSON结果 is compact JSON for automation, 🧩展示结果 the human-readable panel shaped by 🧩输出样式.
Install
Same pack, same steps as everything else in it. Manager → search llama-cpp-dapao / ComfyUI-llama_Dapao, or:
cd ComfyUI/custom_nodes
git clone https://github.com/paolaoshi/ComfyUI-llama_Dapao
python -m pip install -r ComfyUI-llama_Dapao/requirements.txt
That requirements file pins llama-cpp-python to a JamePeng fork commit rather than PyPI, because PyPI's 0.3.35 can't load the newer Qwen GGUFs with MTP/NextN layers (missing tensor 'blk.64.ssm_conv1d.weight'). The git install builds a CPU backend and needs a compiler; on NVIDIA, install the requirements then force-reinstall the matching CUDA wheel from JamePeng's releases over it. Restart ComfyUI, then put your GGUF main model and its mmproj in ComfyUI/models/LLM/ - the loader needs the word mmproj in the projection's filename to list it.
Where it breaks
"本地模型没有返回可解析的JSON" - the node's own error, and it's honest: your GGUF isn't following the format. Raise 📤最大输出token first, then try a stronger instruction-follower. A 3–4B model will hand you a lovely paragraph with a preamble and no JSON, and tolerating that is worse than writing the prompt yourself.
Vision handler failed to load - main model and mmproj aren't a matched pair. The most common local-VLM setup mistake in ComfyUI by a wide margin.
Ratio silently ignored. The ratio lives only in the output ports, never in the prompt - deliberate, so the model doesn't hallucinate resolution text into the description. If nothing downstream consumes wh_ratio, you get your latent's aspect ratio and wonder why the rewrite "did nothing". Wire it, or set width and height by hand.
Parallel queues. Inference is serialized behind a lock, because the pack shares one llama.cpp context. Two firing at once won't race, but they won't run concurrently either.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| 🤖本地模型 | DAPAO_LOCAL_MODEL | — | |
| 📝原始需求 | STRING | — | |
| 🧭任务模式 | COMBO | 自动识别 | 9 options: 自动识别, 文生图, 图像编辑与局部修改, 多图合成, 风格迁移, 背景替换, +3 |
| 📐输出画幅 | COMBO | 自动判断 | 文生图由模型按用途推断;改图可继承基准图,或指定比例。比例只在输出口提供。 |
| 🖼️基准图 | COMBO | 1 | 多图编辑时作为保留原构图的画布。编号按已连接参考图的顺序排列。 |
| 🔤画面文字 | COMBO | 按用户原文与参考图判断 | 4 options: 按用户原文与参考图判断, 禁止新增可读文字, 严格保留用户指定文字, 自定义准确文字 |
| ✍️自定义准确文字 | STRING | 选择“自定义准确文字”时生效;逐字保留并使用直双引号。 | |
| 🧩输出样式 | COMBO | 标准展示(解析+提示词+建议) | 控制展示结果输出口;可用提示词输出口始终保持纯提示词,方便接生图节点。 |
| 📤最大输出token | INT | 2048256–8192 | — |
| 🌡️温度 | FLOAT | 0.350–2 | — |
| 🎲随机种子 | INT | 00–18446744073709550000 | — |
| 🧹为生图释放显存 | BOOLEAN | true | 提示词生成后释放本地LLM显存,给后续Qwen Image生图使用;下次运行会重新加载LLM。 |
| 🖼️参考图1opt | IMAGE | — | |
| 🖼️参考图2opt | IMAGE | — | |
| 🖼️参考图3opt | IMAGE | — | |
| 🖼️参考图4opt | IMAGE | — | |
| 🖼️参考图5opt | IMAGE | — | |
| 🖼️参考图6opt | IMAGE | — | |
| 🖼️参考图7opt | IMAGE | — | |
| 🖼️参考图8opt | IMAGE | — | |
| 🔗上游需求opt | STRING | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| 📋可用提示词 | STRING | — |
| 📐wh_ratio | STRING | — |
| 🖼️ratio_follow | STRING | — |
| 🧾JSON结果 | STRING | — |
| 🧩展示结果 | STRING | — |