Nodes/ComfyUI-PromptEnhancer/Prompt Enhancer (Image-to-Image)
ComfyUI Node

Prompt Enhancer (Image-to-Image)

The node that reads your image and rewrites your edit instruction

By ryan-seungyong-lee·Created 11 months ago·Updated 11 months ago· 8
Prompt Enhancer (Image-to-Image)
  • image
  • enhanced_prompt
edit_instructionRemove the watermark from the bottom
temperature0.10
top_p0.90
max_new_tokens2048
system_prompt

"Remove the watermark from the bottom" is a fine sentence and a terrible edit instruction. Editing models re-emit the whole frame, so the difference between a vague instruction and a precise one isn't polish - it's whether the pixels you never mentioned stay still. PromptEnhancerI2I is the image-to-image half of ComfyUI-PromptEnhancer, and its whole trick is that it looks at the image before rewriting your instruction, so the result names what to change and locks down everything else.

It sits in the same family as the instruction-editor wave that made masks and ControlNets optional for a big chunk of editing work - think Qwen-Image-Edit. You hand the editor a picture and a sentence; the sentence is the part most people get wrong. This node is a vision-language model whose job is to take that sentence and turn it into an editing prompt that preserves the non-edited regions. It's the pack's hidden gem: barely anyone's found it yet (it's the 0-impression sibling to the T2I node), but if you edit images regularly it's the one you'll actually keep.

How it works

Under the hood it's a Qwen2.5-VL model - PromptEnhancer/PromptEnhancer-Img2img-Edit, a ~30GB fine-tune that loads with flash attention and device_map="auto". The node converts the incoming ComfyUI image tensor to a PIL image, writes it to a temp file, and feeds it to the model as a chat message alongside your edit_instruction. The model's default system prompt (Chinese, and worth reading in the source) tells it to rewrite the instruction based on the image while keeping non-edited regions unchanged. The output is your refined instruction as a string. If anything throws, it falls back to returning your original instruction rather than crashing the workflow.

This is the node that earns the pack's biggest asterisk: it requires flash-attn, which is not in requirements.txt. The README is explicit about installing it first, and it's the reason the image-to-image node is fiddlier than the text-to-image one.

The inputs that actually matter

  • image - any image output from your graph (Load Image, VAE Decode, whatever). It reads the first frame of the batch.
  • edit_instruction - your editing request, e.g. "Remove the watermark from the bottom". The default is exactly that.
  • temperature - defaults to 0.1, deliberately low. This is the precision node: you want it to hold the frame still, not get creative. Leave it alone unless you're getting stale outputs.
  • max_new_tokens - default 2048, enough headroom for a detailed instruction that spells out what stays put.
  • system_prompt (optional) - override the default editing-rule behavior if you want a different constraint set.

Output is a single enhanced_prompt string. Wire it into the prompt input of whatever editor your workflow uses - an inpainting model, Qwen-Image-Edit, or a plain img2img KSampler.

Installing it (the fiddly part)

Install the pack the usual way - ComfyUI Manager, search "PromptEnhancer", or:

cd ComfyUI/custom_nodes/
git clone https://github.com/ryan-seungyong-lee/ComfyUI-PromptEnhancer.git
cd ComfyUI-PromptEnhancer
pip install -r requirements.txt

Then, before your first run, install flash attention:

pip install flash-attn --no-build-isolation

That compiles against your torch/CUDA, so it can take 5–10 minutes and will fail loudly if your PyTorch and CUDA versions don't line up. If you'd rather not build it, a prebuilt wheel for your exact torch/CUDA combo is usually faster than fighting the compiler.

Where people get burned

  • The flash-attn build fails. Version mismatch between torch and CUDA is the usual culprit. Align them, or grab a matching prebuilt wheel.
  • The first run looks broken. It's downloading ~30GB, then loading a VL model. Give it a while; later runs use the cache.
  • Out of memory. The img2img model is bf16 and chunky - realistically you want a card with serious VRAM (16GB+ will be comfortable), not the 8GB the 7B T2I node tolerates.
  • Disk space. 30GB model plus room for the temp image file it writes on every run. Make sure there's headroom.

If the pack's GitHub or the HuggingFace repos ever go quiet - the original Hunyuan PromptEnhancer project has been known to disappear and resurface - the model stays local once it's downloaded, and the node keeps working offline. That's the saving grace of the auto-download approach.

Categorypromptenhancer

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
edit_instructionSTRINGRemove the watermark from the bottom
temperatureFLOAT0.100–2
top_pFLOAT0.900–1
max_new_tokensINT2048256–4096
system_promptoptSTRING

Outputs (1)

NameTypeDescription
enhanced_promptSTRING