Sample with Paint-by-Example Pipe
Mask a spot and let a reference image fill it
- pipe
- image
- mask
- example
- IMAGE
Some edits are easy to type and hard to show, and some are the other way round. "Put a red ceramic vase here" - that's words. But what if what you actually have is a photo of the exact vase you want? Paint-by-Example was built for that second case: you mask a region, hand the model a reference image, and it repaints the masked area to match the reference. No prompt at all. The example is the prompt.
That makes this the odd one out in the 2026 inpainting landscape, where instruction-editing models like Qwen-Image-Edit, Flux Kontext and Flux 2 Klein mostly ate the mask's lunch (see the inpainting essay). Those solve "describe it in a sentence." Paint-by-Example solves "show me what you mean" - object transfer, style borrowing, "make this patch look like that thing." It's a 2023 CVPR model and it shows its age, but the niche is real, and this node is the only native ComfyUI route to it.
How it works
The node takes the diffusers pipeline loaded by Load Paint-by-Example Pipe, plus your image, your mask, and your example image. It resizes all three to whatever you set for width and height, converts them to PIL, and calls the official Fantasy-Studio/Paint-by-Example pipeline in one shot. The model - Stable Diffusion 1.4 fine-tuned with a CLIP image encoder - treats your reference image as conditioning and regenerates only the masked region, leaving the rest of the frame alone.
Three inputs matter, and you'll set all three:
mask- draw it the ComfyUI way: white where you want something new, black everywhere you want untouched.example- the reference image. Feed it the thing you want to appear in the mask.image- your source frame, with the mask region still showing what you're replacing.
The width and height ints (default 512×512) are the one real control, and they're a trap if you ignore them: everything gets resized to them, not just the mask. Set them to your source's dimensions, or your whole frame comes back scaled. The example gets resized too, so don't feed a wildly different aspect ratio and expect it to survive.
The output is a single IMAGE, ready for a preview or save node.
The honest limitations
This is a one-shot node with the training wheels bolted on. There's no seed input, no CFG, no step count, no denoise dial - the pipeline runs at its stock defaults every time, so results are not reproducible and you can't nudge "a bit more." That's the biggest practical difference from a normal ComfyUI sampler. And at 512-native with a 2023 base, don't expect 1024px detail: it looks its best at or near the default resolution.
It's also a slow, memory-hungry first step: loading the model pulls roughly 2 GB from HuggingFace, and the sampler holds the whole fp16 pipeline in VRAM. Fine on a 8 GB card, sluggish everywhere else.
Install
ComfyUI Manager: search "ComfyUI-Paint-by-Example". Or the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/Kangkang625/ComfyUI-paint-by-example
# restart ComfyUI
Note this pack ships no requirements.txt, so nothing auto-installs. You need diffusers in ComfyUI's Python environment - pip install diffusers if the node list shows an import error. The loader hardcodes .to("cuda"), so this is NVIDIA-only; no CPU or Apple Silicon fallback.
Common issues
- Node missing after install - almost always
diffusers(oreinops) not installed; the pack has no dependency file, so Manager won't fetch it. - First run hangs - it's downloading the ~2 GB model to
~/.cache/huggingface. Let it finish once; it caches after that. - Output is a resized surprise - you left
width/heightat 512 and your source was bigger. Match them to your image. - Tried to wire the pipe into a normal KSampler - don't. The
MODELsocket here is the raw diffusers pipeline, not a ComfyUI model; only this pack's sampler understands it.
Honest verdict: if "copy the vibe of this reference into a masked patch" is your job, this is the only ComfyUI-native way to do it, and it works. For anything you can describe in words, use a 2026 editor instead - you'll get better results with less fiddling.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| pipe | MODEL | — | |
| image | IMAGE | — | |
| mask | MASK | — | |
| example | IMAGE | — | |
| height | INT | 512 | — |
| width | INT | 512 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |