Nodes/comfyui-timesaver/TS Studio Inpaint Restore
ComfyUI Node

TS Studio Inpaint Restore

Putting the repainted crop back without the VAE's color shift

By AlexYez·Created 2 years ago·Updated a day ago· 12
TS Studio Inpaint Restore
  • image
  • patch
  • plan
  • image

The last step of any crop-based inpaint is the hardest to get right: you have the original full frame and a freshly repainted crop, and you have to put the patch back so nobody can find the seam. Do it naively - resize the patch to the crop size and paste - and two things go wrong: the VAE round-trip has shifted the colors of your repainted region, and the edges sit like a hard rectangle. TS Studio Inpaint Restore is the careful version of that paste: it scales the patch back to native size, neutralizes the color shift the VAE introduced, and composites under a soft edge in linear light. Pair it with TS Studio Inpaint Crop and the whole "only-masked at full detail" pipeline is three nodes long.

How it works

Three inputs, one output, no widgets to fiddle with - the plan does the work:

  • image - the original full frame.
  • patch - the repainted crop, straight out of your inpainting sampler.
  • plan - the TS_INPAINT_PLAN from TS Studio Inpaint Crop, which carries the crop geometry and its soft edge.

The node scales the patch back to the crop's native size, then handles the two classic failure modes. The color shift: any VAE round-trip drifts the color of the regenerated region slightly - encode a patch, decode it, and it no longer matches the surrounding pixels. The crop node deliberately preserves a ring of original pixels around the mask, and this node uses that ring to measure and correct the shift, so the repainted area lands in the same color space as the frame around it. The seam: the patch is composited under the soft edge (the feather_pct value from the crop step) in linear light, which blends gradients - skin, sky, soft shadows - without the muddy look a naive blend gives.

Output is a single image: the full frame with the repainted region composited back, everything outside the mask bit-identical to the source.

The full loop

image + mask → TS Studio Inpaint Crop → crop, crop_mask
                                    ↓
                        any inpainting sampler
                                    ↓
                        repainted patch
                                    ↓
image + patch + plan → TS Studio Inpaint Restore → finished frame

That's the entire "small region at full resolution, untouched pixels bit-exact" recipe - the one thing instruction-edit models still can't give you, and the reason mask-based inpainting survived the Qwen/Kontext takeover.

Install

No extra dependencies - part of comfyui-timesaver.

cd ComfyUI/custom_nodes
git clone https://github.com/AlexYez/comfyui-timesaver
cd comfyui-timesaver
python -m pip install -r requirements.txt

Common issues

  • "The patched area is a different brightness." That's the VAE shift the node is supposed to fix - check that the plan comes from the same crop run as the patch. Feed a plan from a different image and the color ring measures the wrong thing.
  • "I can still see the seam." The soft edge comes from the crop step's feather_pct; if it was set to ~0 there, the restore has no ramp to blend and you get a hard edge. Re-crop with a real feather.
  • "Wrong position." Again the plan - it's geometry, so a plan from a different frame pastes in the wrong place.

The honest scope: this node is pure restoration quality - it doesn't sample, prompt, or invent. But it's the step that makes the whole crop-and-repaint pipeline look like one continuous image instead of a patch glued on.

CategoryTS/Studio

Inputs (3)

NameTypeDefaultDescription
imageIMAGEThe original full frame.
patchIMAGEThe repainted crop.
planTS_INPAINT_PLANPlan from TS Studio Inpaint Crop.

Outputs (1)

NameTypeDescription
imageIMAGE