Nodes/Comfyui-ergouzi-samplers/2🐕Local sampler
ComfyUI Node

2🐕Local sampler

One mask, and the pixels outside it never move

By 11dogzi·Created 2 years ago·Updated 2 years ago· 27
2🐕Local sampler
  • model
  • image
  • vae
  • mask
  • positive
  • negative
  • LATENT
  • IMAGE
  • LocalIMAGE
  • PartialMask
seed0
steps20
cfg8.0
sampler_name
scheduler
denoise0.35
Redraw_Mode
Mask_extension6
Local_Onlytrue
Partial_size512
Region_Extension50
Mask_Feather5
TEXT2🐕

If you've inpainted in ComfyUI before, you know the drill: paint a mask, hand the whole image to a KSampler, and hope the bits you didn't touch come back close to what they were. They usually don't - the VAE encode/decode round trip alone chews up the untouched pixels, which is exactly why the crop-and-stitch pattern won: it never runs the unmasked part through the VAE at all. EGCYQJB, the "2🐕Local sampler," is that idea in a single node. It crops to your mask, redraws only that region at a resolution you choose, and pastes the result back onto the original image. The behavior is exactly right: outside the mask, the output is pixel-identical to what you fed in.

How it works

Unlike a plain KSampler you hand it an IMAGE, a MASK and a VAE, and it does the encode itself. The sample() path is a four-stage loop:

  1. Crop. mask_crop() finds the bounding box of your mask's white pixels, pads it by Region_Extension, and scales the crop so its short side equals Partial_size (512 by default).
  2. Encode. It builds a latent with a proper noise_mask. In Filling mode it flattens the non-mask area of the crop to flat 50% gray before encoding, so the model treats it as "generate here, ignore the rest" - the WebUI-style inpaint-only-masked trick. Original_image keeps the real pixels there as context instead.
  3. Sample. common_ksampler() calls the real comfy.sample.sample() - actual KSampler, actual schedulers, all 34 sampler names.
  4. Stitch. The decoded crop is pasted back at the original coordinates, with Mask_Feather Gaussian-blurring the composite mask so the seam doesn't scream.

That paste-back-from-original step is the whole point. The README's own demo shows it: a normal redraw mangles the untouched area, this one restores it from the source pixels. If it reminds you of Inpaint Crop & Stitch, you're right - same philosophy, fewer moving parts.

The inputs that matter

The plumbing - model, vae, image, mask, positive, negative, sampler_name, scheduler, steps, cfg, seed - is a normal KSampler's. The knobs that actually do the work:

  • Partial_size (512): the resolution the masked region is redrawn at. Crank it for detail, drop toward 384 to keep VRAM happy. Smaller crops get upscaled to fit it, so going above ~768 rarely buys you anything.
  • denoise (default 0.35): low by design, because you're replacing a region, not re-rolling the image. Raise it for a full divergence from what's there, keep it low to blend.
  • Redraw_Mode: Filling blanks the area around the mask before sampling; Original_image feeds the original pixels in as context. Start with Filling; switch when the surroundings need to anchor the new content.
  • Region_Extension (50): padding around the mask so the redraw gets breathing room.
  • Mask_extension (6): grows the mask before sampling - handy if your paint job is sloppy.
  • Local_Only (on): toggles between two nearly identical stitch routines. Leave it on.
  • TEXT: decorative. It's the author's watermark ("2🐕") and does nothing to the output.

Outputs and wiring

  • LATENT - the sampled latent of the crop. Chain it or ignore it.
  • IMAGE - the full image with the redrawn region pasted back. This is the one you preview and save.
  • LocalIMAGE - the raw decoded crop before stitching. Great for checking what the model actually made.
  • PartialMask - the feathered mask, useful if you want to feed the same region somewhere else.

For ControlNet, pair it with EGCYQJBCJ (2🐕Local Image) from the same pack: crop your lineart/pose control to the same region or the control and the sample won't align. The pack ships a lineart workflow showing exactly that wiring.

Installing it

ComfyUI Manager → search "Comfyui-ergouzi-samplers", install, restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/11dogzi/Comfyui-ergouzi-samplers
# then restart ComfyUI

Dependencies are torch, numpy, colorama and pillow - everything ComfyUI already ships - so no model downloads and no heavy install. One heads-up: the module imports torchvision without declaring it, which works only because ComfyUI bundles it. The author, 11dogzi ("二狗子", Ergouzi), is a Chinese Bilibili creator who also makes slider nodes and the HYPIR upscaler; the README is Chinese-first with a rough machine translation, and the code prints a colorful greeting banner to your console on import. Harmless - don't panic at the colors.

Where people get burned

  • Empty mask = crash. If your mask has no white pixels, the internal crop returns a differently-shaped tuple and the node throws. Make sure whatever painted your mask actually painted something.
  • VAE mismatch. Feed the wrong VAE for your checkpoint and the redrawn region comes out as noise or flat color - the usual ComfyUI rule, no exceptions here.
  • Don't read denoise like a txt2img sampler. 0.35 is the sensible start; 0.8+ with Filling mode tends to make the region ignore its surroundings and wander.
  • It's a 2024 pack that's barely maintained. If a ComfyUI update breaks it, look for a fork rather than waiting on the author.

This is the node you reach for when you want "fix just this bit" and can't be bothered to bolt Inpaint Crop + KSampler + Stitch together yourself. It's rough around the edges, but the core promise - untouched pixels stay untouched - it keeps.

Category2🐕sampler

Inputs (19)

NameTypeDefaultDescription
modelMODEL
imageIMAGE
vaeVAE
maskMASK
seedINT00–18446744073709550000
stepsINT201–10000
cfgFLOAT8.00–100
sampler_nameCOMBO34 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +28
schedulerCOMBO9 options: normal, karras, exponential, sgm_uniform, simple, ddim_uniform, +3
positiveCONDITIONING
negativeCONDITIONING
denoiseFLOAT0.350–1
Redraw_ModeCOMBO2 options: Original_image, Filling
Mask_extensionINT60–64
Local_OnlyBOOLEANtrue
Partial_sizeINT5120–2048
Region_ExtensionINT50
Mask_FeatherINT50–100
TEXTSTRING2🐕

Outputs (4)

NameTypeDescription
LATENTLATENT
IMAGEIMAGE
LocalIMAGEIMAGE
PartialMaskMASK