Nodes/ComfyUI_RefineAnything/RefineAnything_Pasteback
ComfyUI Node

RefineAnything_Pasteback

Stitch it back without the sticker look

By smthemex·Created 5 months ago·Updated 4 months ago· 33
RefineAnything_Pasteback
  • generated_image
  • cond
  • image
  • transparent_bg
mask_grow3
blend_blur5
adaintrue
waveletfalse
save_rgbatrue

So you cropped to the mask, ran the sampler, and now you have a beautifully refined region floating in space. Slap it back onto the original and you get the classic failure: a hard seam and a region that's technically fixed but looks pasted on, because the edit model's lighting never quite matched the surrounding photo. RefineAnything_Pasteback is the other half of the pack, and its whole job is to make that patch disappear.

How it works

It's crop-and-stitch with the polish bolted on. The node takes your generated crop and the cond context from RefineAnything_PreImg, then:

  • Grows the mask (mask_grow, default 3) with a max filter so the blend area extends a few pixels past the boundary instead of cutting on a hairline.
  • Blurs it (blend_blur, default 5) so the alpha falloff is gradual - the modern equivalent of feathering an inpaint mask.
  • Blends through that mask, with color alignment on top so the patch picks up the original's local tone rather than carrying its own.

That last bit is the difference between "fixed" and "seamless". By default adain is on, which runs an adaptive-instance-normalization color fix (borrowed from the well-known sd-webui colorfix trick) to transfer the surrounding image's color and lighting statistics onto the crop before compositing. Leave it on; it's the reason the result doesn't scream "I was inpainted."

The inputs that matter

  • generated_image - the decoded output of your sampler, i.e. the edited crop. Wire KSampler → VAE Decode → here.
  • cond - the conditioning output from RefineAnything_PreImg, same run. It carries the original image, the cropped mask, and the crop coordinates. This is why you mustn't rebuild the graph between runs: a cond from a different image or a different crop will paste in the wrong place.
  • adain (default on) - the color-alignment switch. Keep it on for photos.
  • wavelet (default off) - a heavier wavelet-based color reconstruction, if AdaIN flattens the tone and you need finer low-frequency matching. Slower, and it switches the compositing code path, so test it before relying on it.
  • mask_grow / blend_blur - seam control. Crank blend_blur if you see a boundary; dial it down if the fix bleeds into untouched areas.
  • save_rgba (default on) - writes the composited region out as a transparent PNG into your ComfyUI output folder.

Outputs

image is the full original with the refined region composited in - that's your final result. transparent_bg is the edited crop alone on a transparent background, which is genuinely useful if you're doing sprite or product work and want to drop the fixed region onto a different background. Note that transparent RGBA doesn't preview meaningfully in a plain Preview Image node, so don't panic if it looks black there.

Installing

No extra dependencies - it ships in the pack's single __init__.py. ComfyUI Manager: search ComfyUI_RefineAnything, or:

cd ComfyUI/custom_nodes
git clone https://github.com/smthemex/ComfyUI_RefineAnything

Restart and the node appears. The model side is the real work: the RefineAnything LoRA from limuloo1999/RefineAnything on Hugging Face plus a Qwen-Image-Edit-2511 stack (diffusion model, CLIP, VAE). A 20B model, so on most consumer GPUs you'll want a GGUF quant.

Troubleshooting

  • Seam still visible with adain on. Raise blend_blur first, then try wavelet on. If it still shifts, the culprit may not be here at all - community reports on the example workflow's Edit Model Reference Method node say index_timestep_zero produces a noticeable color shift, and switching to index or another method fixes it upstream.
  • The patch lands in the wrong place. Your cond and generated_image don't match - they must come from the same PreImg/sampler run.
  • transparent_bg looks broken. It's RGBA; preview it via a node that handles alpha or just look at the saved PNG.
CategoryRefineAnything

Inputs (7)

NameTypeDefaultDescription
generated_imageIMAGE
condCONDITIONING
mask_growINT30–4097
blend_blurINT50–4096
adainBOOLEANtrue
waveletBOOLEANfalse
save_rgbaBOOLEANtrue

Outputs (2)

NameTypeDescription
imageIMAGE
transparent_bgIMAGE