Nodes/ComfyUI-Apt_Preset/pre_inpaint_sum
ComfyUI Node

pre_inpaint_sum

Native inpaint or ControlNet inpaint, switched by one dropdown

By cardenluo·Created 2 years ago·Updated 17 days ago· 309
pre_inpaint_sum
  • context
  • latent_image
  • latent_mask
  • context
  • positive
  • negative
  • latent
control_netNone
mask_modeAilmama
smoothness0.0
strength1.00
start_percent0.000
end_percent1.000

Inpainting splits into two genuinely different mechanisms depending on your model - plain "mask a region and regenerate it" conditioning that works on anything, or a dedicated inpainting ControlNet trained specifically to understand mask boundaries. pre_inpaint_sum covers both from one node: leave control_net on None and it uses ComfyUI's native inpaint conditioning; pick a checkpoint and it switches to ControlNet-based inpainting instead. Which one you want depends entirely on your base model and how much of a redo you're asking for.

Part of Apt_Preset's chx_tool/controlnet category and its RUN_CONTEXT chain, alongside pre_controlnet and pre_controlnet_union.

How it works

No ControlNet selected (mode one): the node builds native inpaint conditioning directly - the same territory as ComfyUI's InpaintModelConditioning. The node's own guidance splits this into two use cases: low-noise repaint, which works on any model and suits detail fixes and small tweaks; and high-noise repaint, which suits image-editing models specifically (Qwen-Image-Edit, Kontext) where you're asking for a fuller regeneration of the masked region rather than a subtle touch-up.

A ControlNet selected (mode two): it switches to ControlNet-based inpainting, and mask_mode decides how the masked-out pixels get prepped before that ControlNet sees them - as a black block, a white block, or a gray block. The node's own documentation is specific about which pairing goes with which base model: SD1.5 repaint wants mask_black, SDXL wants mask_white, and both Flux and Qwen-Image repaint want Alimama's dedicated inpainting ControlNet (the fourth mask_mode option, listed first and default). This tracks with the wider community's own two-track answer on inpainting: standard model inpainting works everywhere but can seam and color-mismatch at the edges, where a dedicated inpainting ControlNet is trained specifically on masked pairs and blends the boundary better.

One schema quirk worth knowing before you wire this: latent_image is typed IMAGE, not LATENT, despite the name. You feed it the actual image, not a pre-encoded latent - the node handles encoding internally as part of building the inpaint conditioning. If you go looking for a LATENT socket to plug in here, you won't find one; that's not a bug, just a leftover name from wherever this was copied from.

Inputs and outputs

  • context (required) - the RUN_CONTEXT chain.
  • control_net - None for native inpaint mode, or a checkpoint to switch to ControlNet mode.
  • mask_mode - Ailmama (the pack's own spelling of Alimama, default), mask_black, mask_white, mask_gray. Only matters in ControlNet mode.
  • latent_image - despite the name, this is an IMAGE input, not LATENT.
  • latent_mask - the MASK marking what to regenerate.
  • smoothness (0–20, default 0) - mask edge feathering.
  • strength (0–10, default 1), start_percent / end_percent (0–1, default 0/1) - standard ControlNet-style strength and timing controls, relevant in ControlNet mode.

Outputs: context, positive, negative (CONDITIONING), and latent (LATENT) - ready for a sampler.

Installing it

ComfyUI Manager: search "ComfyUI-Apt_Preset", install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git

Restart after. install.bat for Windows dependencies; Linux/Mac, install from the requirements file inside your ComfyUI venv. If you're using ControlNet mode with mask_mode set to the Alimama option, you need Alimama's FLUX/Qwen-Image inpainting ControlNet checkpoint downloaded and sitting in your ControlNet folder yourself - it doesn't ship with the pack, and control_net will only offer checkpoints ComfyUI can already see.

Common issues

Wired an IMAGE where you expected a LATENT (or vice versa) into latent_image. This is the node's own naming, not a mistake on your end - despite the name, the input type is IMAGE. Feed it the image directly.

Repaint edges look seamed or color-mismatched. That's the signature failure of native/mask-based inpainting on a model with no inpainting-specific training. If you're on mode one (no ControlNet) and hitting this, switching to ControlNet mode with the right mask_mode for your base model is exactly the fix this node is built to offer.

Picked the wrong mask_mode for your base model. These aren't interchangeable - SD1.5 wants mask_black, SDXL wants mask_white, Flux and Qwen-Image want the Alimama option. Using the wrong one against a ControlNet trained for a different preprocessing convention will degrade results even with everything else set correctly.

High-noise repaint on an edit model (Kontext, Qwen-Image-Edit) still shifts pixels outside the mask slightly. That's a known limitation of edit models generally, not specific to this node - they re-emit the whole frame from context, so unmasked regions come back close but not bit-identical. If you need the rest of the image to stay completely untouched, native low-noise inpainting on a non-edit model is the more reliable choice for that specific requirement.

CategoryApt_Preset/chx_tool/controlnet

Inputs (9)

NameTypeDefaultDescription
contextRUN_CONTEXT
control_netCOMBONone1 options: None
mask_modeCOMBOAilmama4 options: Ailmama, mask_black, mask_white, mask_gray
latent_imageIMAGE
latent_maskMASK
smoothnessFLOAT0.00–20
strengthFLOAT1.000–10
start_percentFLOAT0.0000–1
end_percentFLOAT1.0000–1

Outputs (4)

NameTypeDescription
contextRUN_CONTEXT
positiveCONDITIONING
negativeCONDITIONING
latentLATENT