Nodes/Comfyui_LG_Tools/AFL Target restoreV2
ComfyUI Node

AFL Target restoreV2

Paste your inpainted crop back, edges feathered, no visible seam

By LAOGOU-666·Created 2 years ago·Updated 7 months ago· 369
AFL Target restoreV2
  • original_image
  • processed_image
  • crop_box
  • mask
  • restored_image
blur_amount0
mask_expand0

AFL2:ImageRestoreNodeV2 ("AFL Target restoreV2") is the second half of the pack's crop → inpaint → paste-back loop, and its description tells you exactly what it does: "paste the processed image back onto the original." You give it the original image, the region you cropped and inpainted, the crop coordinates from the crop node, and it stitches the edited region back in - with control over how the edges blend so you don't get a hard rectangle staring out of your photo.

This is the step that makes or breaks the whole workflow. A crop-inpaint loop that pastes a hard-edged box back is useless; one that feathers the boundary and lets the inpaint breathe into the original looks like the object was always there. The KB's inpainting doc frames why you bother in the first place: only mask-based inpainting keeps the unmasked pixels bit-identical, and this node is how you get those edited pixels back into the untouched original without a visible seam.

How the mechanism works

The node resizes the processed (inpainted) crop to the original crop coordinates, then blends it into the original. Two knobs control the blend quality:

  • blur_amount (INT, 0–500, default 0) - edge feathering. Applies a Gaussian blur to the mask edge (or the bbox edge if you didn't provide a mask), which softens the transition between inpainted and original pixels. This is the "no seam" dial; start small and increase until the boundary disappears.
  • mask_expand (INT, −500 to 500, default 0) - expands (positive) or shrinks (negative) the blend mask. Expand when the inpaint leaves a thin un-edited halo at the border; shrink when you're bleeding into the original.

There's also an optional mask (MASK) input - hand it the cropped mask from the crop node for edge-aware blending, or leave it empty and it falls back to blurring the bbox edge.

The inputs that matter

  • original_image (IMAGE) - the untouched original.
  • processed_image (IMAGE) - the inpainted/edited crop.
  • crop_box (CROPBOX) - the coordinates; plug this straight from AFL2:MaskBoxCropNodeV2's crop_box output. They must match, or the paste lands in the wrong place.
  • blur_amount and mask_expand - the two knobs above.

One output: restored_image (IMAGE) - the original with the edited region pasted back and blended.

Installing it

Part of Comfyui_LG_Tools:

cd ComfyUI/custom_nodes
git clone https://github.com/LAOGOU-666/Comfyui_LG_Tools.git
pip install -r requirements.txt

Or via ComfyUI Manager → "Comfyui_LG_Tools" → restart. It's under Add Node → AFL → Mask.

Common issues

  • "The patch lands in the wrong place." Crop box mismatch. Regenerate the crop box from the same crop node run that produced your inpainted image - coordinates are positional, not magic.
  • "Visible rectangle edges." You need blur_amount > 0. It defaults to 0 (no feathering), so the first run always looks hard-edged until you dial it in.
  • "The patch is smaller/larger than the hole." The processed image gets resized to fit the crop box, so a mismatched aspect ratio shows up as distortion - crop with the ratio locked (e.g. 1:1) to keep this clean.

When it's wired correctly, this crop-restore pair is quietly excellent - it's the missing "paste back" step that turns a crop-and-inpaint experiment into a real inpainting workflow.

CategoryAFL/Mask

Inputs (6)

NameTypeDefaultDescription
original_imageIMAGE
processed_imageIMAGE
crop_boxCROPBOX
blur_amountINT00–500边缘羽化值,对mask边缘或bbox边缘应用高斯模糊
mask_expandINT0-500–500遮罩扩展值,正值扩展,负值收缩
maskoptMASK

Outputs (1)

NameTypeDescription
restored_imageIMAGE