ComfyUI Node Runs on cloud

Inpaint Preprocessor

Prep an image and mask for an inpaint ControlNet

By Fannovel16·Created 3 years ago·Updated 4 months ago· 4,134
Inpaint Preprocessor
  • image
  • mask
  • IMAGE
black_pixel_for_xinsir_cnfalse

This node takes an image and a mask and prepares them for an inpaint ControlNet - it marks the masked region so the ControlNet knows exactly where to regenerate and where to leave alone. It's the odd one out in this pack: the README notes that every preprocessor except Inpaint is folded into the AIO node, and this is that exception. It's small, it's specific, and if you're doing ControlNet-guided inpainting it's the piece that connects your mask to the model.

Why an inpaint ControlNet at all

Regular checkpoint inpainting works, but an inpaint ControlNet - where the mask itself becomes the conditioning - tends to give better edge blending, because the ControlNet was trained to be mask-aware and reconcile the repainted region with its surroundings. That's the payoff: cleaner seams than a bare inpaint. This preprocessor is the required first step in that workflow. It encodes the masked area into the image (the masked pixels get set to the "regenerate me" value the ControlNet expects) so the downstream ControlNet reads your intent correctly.

The inputs that matter

Note that unlike most nodes in this pack, this one has a required mask input - it needs both pieces:

  • image (required) - the picture you're editing.
  • mask (required) - the region to regenerate. White is the area to repaint, black is what stays. Wire in a mask from a Load Image (as mask), a mask editor, or any masking node.
  • black_pixel_for_xinsir_cn (default false) - a compatibility switch. xinsir's inpaint ControlNet expects the masked region encoded as black pixels rather than the default treatment; flip this to true only if you're pairing with that specific model. For the standard SD1.5 inpaint ControlNet, leave it off.

The single output is an IMAGE - the prepped image with the masked region marked - which goes into a ControlNet Apply node with an inpaint ControlNet model. The node prepares the hint; the inpaint ControlNet does the conditioning.

Installing it

ComfyUI Manager: search ComfyUI's ControlNet Auxiliary Preprocessors, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/Fannovel16/comfyui_controlnet_aux
pip install -r requirements.txt

Restart ComfyUI. This node is a lightweight image operation - no neural weights to download - so it runs instantly.

Where people get burned

First, the compatibility flag catches people out. black_pixel_for_xinsir_cn defaults to off for a reason: on a standard inpaint ControlNet, turning it on gives you wrong results, and on the xinsir model, leaving it off does the same. Match the switch to your ControlNet, and if your inpaint result is bizarre, this is the first thing to check. Second - the theme of this whole pack - this preprocessor does nothing on its own; you need an inpaint ControlNet loaded and this node's output wired into it, plus the mask carried through to your sampler's inpaint path. Third, mask polarity: make sure white marks the region you want changed. An inverted mask repaints everything except what you meant to edit, which is a classic five-minutes-of-confusion bug. Finally, note the landscape has shifted - on modern base models (Flux, Z-Image, Qwen), inpainting increasingly ships as a mode of the union ControlNet rather than a separate preprocessor-plus-model dance. This node lives squarely in the SD1.5/SDXL inpaint-ControlNet world, which is where it still does exactly its job.

CategoryControlNet Preprocessors/others

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
maskMASK
black_pixel_for_xinsir_cnoptBOOLEANfalse

Outputs (1)

NameTypeDescription
IMAGEIMAGE