comfyui-inpaint-nodes

comfyui-inpaint-nodes
★ 1,152

修补节点遮罩预处理SDXL兼容Fooocus支持
为 ComfyUI 提供更强的 inpaint 节点,新增多种遮罩预处理方式,支持将 Fooocus inpaint 小补丁应用于任意 SDXL checkpoint,提升遮罩区域生成一致性。
💡 通过预处理和 Fooocus 补丁提升 SDXL 等模型的遮罩区域一致性。
🍴 68 Forks💻 Python🔄 2026-03-21
📦
网盘下载
复制链接后前往夸克网盘下载
https://pan.quark.cn/s/b45acaa3411d
Inpaint workflow
input
neutral
telea
ns
blur-17
blur-65
lama
mat
📄 README

ComfyUI Inpaint Nodes

Nodes for better inpainting with ComfyUI: Fooocus inpaint model for SDXL, LaMa, MAT,

and various other tools for pre-filling inpaint & outpaint areas.

Fooocus Inpaint

Adds two nodes which allow using Fooocus inpaint model.

It’s a small and flexible patch which can be applied to your _SDXL checkpoints_ and

will transform them into an inpaint model. This model can then be used like other inpaint

models to seamlessly fill and expand areas in an image.

Download models from lllyasviel/fooocus_inpaint and place them into ComfyUI/models/inpaint.

[!NOTE]

Make sure to use the regular version of a checkpoint to create an inpaint model – distilled merges (Turbo, Lightning, Hyper) do not work.

Inpaint Conditioning

Fooocus inpaint can be used with ComfyUI’s _VAE Encode (for Inpainting)_ directly. However this does

not allow existing content in the masked area, denoise strength must be 1.0.

_InpaintModelConditioning_ can be used to combine inpaint models with existing content. The resulting

latent can however _not_ be used directly to patch the model using _Apply Fooocus Inpaint_. This repository

adds a new node VAE Encode & Inpaint Conditioning which provides two outputs: latent_inpaint (connect

this to _Apply Fooocus Inpaint_) and latent_samples (connect this to _KSampler_).

It’s the same as using both _VAE Encode (for Inpainting)_ and _InpaintModelConditioning_, but less overhead

because it avoids VAE-encoding the image twice. Example workflow

Inpaint Pre-processing

Several nodes are available to fill the masked area prior to inpainting. They avoid seams as long as the

input mask is large enough.

Expand Mask

Expands (grow) a binary mask by a certain number of pixels, and optionally blurs (feather) the mask for a smoother transition at the edges.

Shrink Mask

Shrinks (erodes) a binary mask by a certain number of pixels, and optionally blurs (feather) the mask for a smoother transition at the edges.

Stabilize Mask

Maps mask values very close to 1 to be exactly 1.0. This helps avoid numerical

issues introduced by previous operations. ComfyUI in various steps only

considers noise masks to be opaque when they are >= 1.0 (eg. via round), and

values like 0.9999… can lead to masks not working at all.

Fill Masked

This fills the masked area, with a smooth transition at the border. It has 3 modes:

  • neutral: fills with grey, good for adding entirely new content
  • telea: fills with colors from surrounding border (based on algorithm by Alexandru Telea)
  • navier-stokes: fills with colors from surrounding border (based on fluid dynamics described by Navier-Stokes)
  • | Input | Neutral | Telea | Navier-Stokes |

    |-|-|-|-|

    | | | |

    Blur Masked

    This blurs the image into the masked area. The blur is less strong at the borders of the mask.

    Good for keeping the general colors the same.

    | Input | Blur radius 17 | Blur radius 65 |

    |-|-|-|

    | | | |

    Inpaint Models (LaMA, MAT)

    This runs a small, fast inpaint model on the masked area. Models can be loaded with Load Inpaint Model

    and are applied with the Inpaint (using Model) node. This works well for outpainting or object removal.

    The following inpaint models are supported, place them in ComfyUI/models/inpaint:

  • LaMa | Model download
  • MAT | Model download | Model download (fp16 safetensors)
  • | Input | LaMa | MAT |

    |-|-|-|

    | | | |

    Inpaint Post-processing

    Color Match (Masked)

    Can mitigate color/brightness shifts when inpainting. Requires the original

    input image as reference, and the denoising output as target. This node is

    useful only if the color shift occurs in the entire output, even the parts that

    were excluded with a _noise mask_. In this case you can provide the same mask to

    the Color match node as exclude mask. Colors will be anaylised based on the

    changes _outside_ the masked area. Then the correction is applied to the entire

    target image.

    Particularly useful for refinements or edits done with Flux 2 Klein.

    Denoise to Compositing Mask

    Takes a _mask_, an _offset_ (default 0.1) and a _threshold_ (default 0.2).

    Maps mask values in the range of \[_offset_ → _threshold_\] to \[0 → 1\].

    Values below offset are clamped to 0, values above threshold to 1.

    This is particularly useful in combination with ComfyUI’s “Differential Diffusion” node, which allows to use a mask as per-pixel denoise strength.

    Using the same mask for compositing (alpha blending) defeats the purpose, but no blending at all degrades quality in regions with zero or very low strength. This node creates a mask suitable for blending from the denoise-mask.

    Example Workflows

    Example workflows can be found in workflows.

  • Simple: basic workflow, ignore previous content, 100% replacement
  • Refine: advanced workflow, refine existing content, 1-100% denoise strength
  • Outpaint: workflow for outpainting with pre-processing
  • Pre-process: complex workflow for experimenting with pre-processors
  • Promptless: same as above but without text prompt, requires IP-Adapter
  • Installation

    Use ComfyUI Manager and search for “ComfyUI Inpaint Nodes”.

    _or_ download the repository and put the folder into ComfyUI/custom_nodes.

    _or_ use GIT:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Acly/comfyui-inpaint-nodes.git

    Restart ComfyUI after installing!


    OpenCV is required for _telea_ and _navier-stokes_ fill mode:

    pip install opencv-python

    Acknowledgements

  • Fooocus Inpaint: lllyasviel/Fooocus
  • LaMa: advimman/lama
  • MAT: fenglinglwb/MAT
  • LaMa/MAT implementation: chaiNNer-org/spandrel