Nodes/ComfyUI_agilly1989_motorway/InpaintModelConditioning_motorway_edition
ComfyUI Node

InpaintModelConditioning_motorway_edition

Proper masked inpainting conditioning, via the pipe

By agilly1989·Created 2 years ago·Updated about a year ago· 7
InpaintModelConditioning_motorway_edition
  • MOTORWAY 🚌💨
  • MOTORWAY 🚌💨
INPUT_positive_keypositive
INPUT_negative_keynegative
INPUT_vae_keyvae
INPUT_pixels_keypixels
INPUT_mask_keymask
noise_masktrue
OUTPUT_positive_keypositive
OUTPUT_negative_keynegative
OUTPUT_latent_keylatent

InpaintModelConditioning_motorway_edition wraps the core node that makes masked inpainting work properly on models that weren't trained with a dedicated inpaint checkpoint. Its inputs - positive, negative, VAE, image pixels and mask - all come out of the Motorway by key, and the outputs go back into the pipe. Under the hood it's doing the same thing as core's InpaintModelConditioning: it encodes the image with the mask baked into the latent, and produces conditioned positive/negative to feed the sampler.

Why this node (not the shortcut)

The KB is pretty clear that the naive way to inpaint - blank the region, generate into it with a normal sampler - produces latent bleeding where the model paints the masked area as if it's part of the same continuous canvas. InpaintModelConditioning is the fix: it marks the masked latent so sampling only happens inside the mask. On the 2026-era flow-matching models people explicitly call it out as the right call - "use the InpaintModelConditioning node instead of an empty latent" is the advice you see from people doing true masked inpainting with Qwen-Image and Klein. It's not an alternative to an inpaint-specific checkpoint; it's how you get masked inpainting from models that don't have one.

The one widget, noise_mask (default true), is worth understanding because its tooltip is unusually honest: add a noise mask so sampling happens only within the mask - "might improve results or completely break things depending on the model." When it works it stops the outside of the mask from being touched; when the model hates it, you flip it off and take the bleeding. That's a try-it-both-ways setting, not a set-and-forget.

The motorway wiring

Everything except noise_mask is a key field:

  • INPUT_positive_key / INPUT_negative_key (defaults "positive" / "negative")
  • INPUT_vae_key (default "vae")
  • INPUT_pixels_key (default "pixels") - the masked image
  • INPUT_mask_key (default "mask")
  • Outputs: OUTPUT_positive_key / OUTPUT_negative_key (defaults "positive" / "negative") and OUTPUT_latent_key (default "latent").

Note the output defaults mirror the input defaults: the conditioned positive/negative overwrite the originals in the pipe, which is exactly what you want, since the sampler downstream reads the same "positive" / "negative" keys. The only output socket is MOTORWAY 🚌💨, so the conditioned latent is reached by reading "latent" out via a Motorway AxB ramp and feeding a KSampler (motorway-ed or not).

Install and the usual suspects

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

Restart ComfyUI, or use ComfyUI Manager. No extra pip deps, no model files - this node orchestrates VAE + mask, it doesn't load weights.

Pack-wide reality check, because it applies: this is a one-dev beta project and the repo is mid-refactor. The current HEAD has the _motorway_edition registration commented out, so on a fresh clone the node may not load at all; the README's "IF THINGS BREAK ITS BECAUSE I BROKE IT" is doing real work. And if a run dies with 'MotorwayClass' object has no attribute 'hash_', a key you set was never written to the pipe - double-check the spelling of your mask and pixel keys, since those are the ones people usually wire in from a segmenter and typo. The core InpaintModelConditioning is the same logic without the pipe if you're not committed to the motorway.

Categoryagilly1989 Nodes/Motorway-ed/conditioning/inpaint

Inputs (10)

NameTypeDefaultDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨
INPUT_positive_keySTRINGpositive
INPUT_negative_keySTRINGnegative
INPUT_vae_keySTRINGvae
INPUT_pixels_keySTRINGpixels
INPUT_mask_keySTRINGmask
noise_maskBOOLEANtrueAdd a noise mask to the latent so sampling will only happen within the mask. Might improve results or completely break things depending on the model.
OUTPUT_positive_keySTRINGpositive
OUTPUT_negative_keySTRINGnegative
OUTPUT_latent_keySTRINGlatent

Outputs (1)

NameTypeDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨