InsertAnything - Fill Process
The node that builds InsertAnything's diptych
- source_image
- ref_image
- source_mask
- ref_mask
- image
- mask
- old_tar_image
- tar_box_yyxx_crop
- crop_params
- preview_image
The heart of the pack
If you only read one page about InsertAnything, read this one. Fill Process is where the actual "insert anything" happens. It takes your reference object, your target scene, and two masks, and turns them into a single diptych - reference image on the left, cropped target region on the right - plus one mask that tells the model which half it's allowed to fill. The Flux Fill UNet then regenerates that whole frame, and the result is an object that has been lit, shadowed, and blended into your scene.
This is the paper's actual trick. Insert Anything (AAAI'26, from the WensongSong group) is "in-context editing in DiT": instead of describing the object in text, you hand the model a picture of it. No prompt, no IP-Adapter, just "here's the thing, here's the space, fill it." That's why the reference half of the diptych is left completely intact - it's context, not canvas.
What it does to your images
Walk through the geometry and it makes sense:
- Reference side - strips the background out of
ref_imageusingref_mask(background goes white), crops to the object's bounding box, expands it ~1.3x, pads to square. - Target side - dilates
source_maskwith a 7x7 kernel,iterationstimes. This is the input you'll actually touch: more iterations = fatter fill region = more room for the model to blend the edges. Default 2. - Box math - finds the dilated mask's bounding box, expands it, squares it up, pads the crop to square. Both halves get resized to 768x768.
- Assemble - concatenates
[reference | target crop]side by side and builds a matching mask that's black on the reference half and the dilated target mask on the right.
The inputs and outputs that matter
source_image+source_mask- your scene and where the object goes.ref_image+ref_mask- the thing being inserted and its outline.iterations- mask dilation count (INT, default 2). This is the one knob most people actually turn. Painted masks that hug the subject too tightly produce visible seams; a couple of extra iterations gives the model breathing room.
Outputs, and where they go:
image+mask- the diptych and its mask. These feed InpaintModelConditioning alongside the Redux-processed reference, which is what makes the sampler blend with surrounding context.old_tar_image- a pristine copy of the original, kept for the stitch-back.tar_box_yyxx_crop(BOX) andcrop_params(CROP_PARAMS) - the geometry bookkeeping Crop Back needs to paste the result home.preview_image- the diptych with the fill region highlighted, so you can sanity-check the mask before you spend a generation on it. Look at this one.
Install
ComfyUI Manager: search InsertAnything, or install via Git URL https://github.com/mo230761/InsertAnything-ComfyUI-official.git. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/mo230761/InsertAnything-ComfyUI-official.git
Restart, then drop InsertAnything.json into ComfyUI/user/default/workflows. The pack has no requirements.txt but imports cv2 and diffusers at load time - if it won't import, pip install opencv-python diffusers into the ComfyUI env. Model files the workflow expects: flux1-fill-dev (fp8 recommended), flux1-redux-dev + SigLIP vision, SD3 clip_l + t5xxl_fp8, flux-ae, and the insert-anything-lora.safetensors from HuggingFace (WensongSong/Insert-Anything). Plan for ~26 GB VRAM on the standard route.
Gotchas
- The mask must fully cover what you want edited - the authors say this explicitly. A partial mask gets binarized at 128 and then dilated, but if it never touched the object edge, the model fills context, not the object.
- 768×768 is a real trade. The scaled pipeline downsampling your crop loses fine texture at large resolutions. If your insertion region is big, that's not a Fill Process bug - it's exactly why the pack ships FillProcessNoScaling.
- The
imageoutput is a diptych, not your final photo. Preview it, sample it, but save the output of Crop Back, not this.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| source_image | IMAGE | — | |
| ref_image | IMAGE | — | |
| source_mask | MASK | — | |
| ref_mask | MASK | — | |
| iterations | INT | 2 | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| old_tar_image | IMAGE | — |
| tar_box_yyxx_crop | BOX | — |
| crop_params | CROP_PARAMS | — |
| preview_image | IMAGE | — |