Adaptive Params (Model Choice + Passthrough)
Inpainting settings that compute themselves — and pass your mask through untouched
- image
- mask
- image_out
- mask_out
- context_from_mask_extend_factor
- mask_expand_pixels
- mask_blend_pixels
- target_size_out
This node never touches a pixel, which is exactly why you want it. In a classic mask-based inpainting workflow - the kind that still survives even after Flux Kontext and Qwen-Image-Edit took over most editing - you spend forever fiddling with the same four numbers: how much context to give the model around the mask, how far to expand the mask, how much to feather the edge, and what resolution to work at. Adaptive Params (Model Choice + Passthrough) measures your mask and fills those numbers in for you.
It's a fork of a-und-b/ComfyUI_MaskAreaCondition with a model selector bolted on, and it lands in a grab-bag pack (gayratv/ComfyUI_Gayrat) that has basically zero community footprint - 0 search impressions, nothing on Reddit. So treat it as a personal tool that happens to be published, not a polished release. Read the source if something surprises you.
How it works
The mechanism is simple enough to hold in your head. It counts how many pixels in your mask are "active" (above zero), divides by the total image area, and gets a percentage. Then it picks from three bands:
- Mask under 10% of the image → context factor 2.0, expand 6px, blend 12px. A small hole needs lots of surrounding context so the model understands what's there.
- 10–40% → context 1.5, expand 12px, blend 24px. The middle ground.
- Over 40% → context 1.1, expand 24px, blend 48px. Most of the frame is changing anyway, so the model doesn't need context - but the bigger expansion and blend smooth the transitions.
The model_type dropdown only decides one thing: target_size_out - 1024 for Flux, 512 for SD 1.5, matching what each model was trained at. Everything else is driven by your mask.
The inputs and outputs that matter
Required inputs: image, mask, and model_type (Flux or SD 1.5). Feed it the same image and mask you're already passing toward VAEEncodeForInpaint.
Outputs:
image_out/mask_out- your image and mask, passed through byte-for-byte. You can chain this node inline without disturbing the data.context_from_mask_extend_factor(FLOAT),mask_expand_pixels(INT),mask_blend_pixels(INT) - the three computed values, named after the exact slots onVAEEncodeForInpaint.target_size_out(INT) - the model's native size.
Wire the three parameters into your inpaint encode node, and you never hand-tune context/expand/blend again. That's the whole job. If you switch masks mid-workflow - a tiny face fix to a full object removal - the values rescale themselves on the next run.
Install
ComfyUI Manager is the easy route: search ComfyUI_Gayrat (the pack title) and install. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/gayratv/ComfyUI_Gayrat
cd ComfyUI_Gayrat
pip install -r requirements.txt
Then restart ComfyUI. It appears under the Gayrat menu. The pack pulls in a dozen other nodes you may not want - fine, they just sit there. Its requirements.txt wants googletrans, requests, aiohttp, blend_modes, httpx plus the usual torch/Pillow/numpy that ComfyUI already ships.
Gotchas
The outputs are bare numbers with no type magic - they're meant for VAEEncodeForInpaint's matching inputs, and if your target node names its fields differently you'll be matching by eye. And the three bands are hard-coded; if your mask sits right at the 10% or 40% boundary, you'll feel the jump. For most people this beats remembering "small mask, big context" - and it turns a fiddly inpaint graph into one that re-tunes itself.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| model_type | COMBO | Flux | 2 options: Flux, SD 1.5 |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| image_out | IMAGE | — |
| mask_out | MASK | — |
| context_from_mask_extend_factor | FLOAT | — |
| mask_expand_pixels | INT | — |
| mask_blend_pixels | INT | — |
| target_size_out | INT | — |