Nodes/ComfyUI Impact Pack/RegionalSampler
ComfyUI Node Runs on cloud

RegionalSampler

Paint different prompts into different parts of one image

By ltdrdata·Created 3 years ago·Updated 4 months ago· 3,242
RegionalSampler
  • samples
  • base_sampler
  • regional_prompts
  • LATENT
seed0
seed_2nd0
seed_2nd_mode
steps20
base_only_steps2
denoise1.00
overlap_factor10
restore_latenttrue
additional_moderatio between
additional_sampler
additional_sigma_ratio0.30

You want a red-haired woman on the left and a blue-robed wizard on the right, in one generation, without them bleeding into each other. That's what RegionalSampler is for. You hand it a base sampler for the whole canvas plus a set of masked regions, each with its own sampler and prompt, and it samples every region during each step rather than as a separate pass afterward. That "during each step" is the whole point - it's what makes the regions actually blend into a coherent image instead of looking pasted together.

It lives in ltdrdata's Impact Pack, the same detect-crop-refine toolbox behind FaceDetailer. Regional sampling is a smaller, nerdier corner of the pack than the detailer stuff, and it shows: this is one of the fiddlier nodes ltdrdata ships. Half the threads you'll find about it are people trying to get it to run at all. Go in expecting to spend some time wiring.

How it works

Sampling happens per step. The base sampler advances the entire latent one step, then each regional sampler re-samples its masked area toward its own prompt, then the next step runs, and so on. Because the regions are refined in lockstep with the base rather than bolted on at the end, the seams stay soft. This is the key difference from TwoSamplersForMask, which finishes the base area completely before touching the masked one.

The regions themselves come from RegionalPrompt nodes (mask + an advanced sampler), combined with CombineRegionalPrompts if you have several.

The inputs and outputs that matter

  • base_sampler (KSAMPLER_ADVANCED) - the sampler for everything outside your masks. Build it from KSamplerAdvancedProvider.
  • regional_prompts (REGIONAL_PROMPTS) - your masked regions, one per subject. This is the input that makes the node do its job.
  • samples (LATENT) - the latent you're sampling, usually an empty latent at your target size.
  • base_only_steps (default 2) - how many opening steps run the base sampler alone before the regions kick in. A couple of steps here lets the overall composition settle first.
  • overlap_factor (default 10) - how far each region reaches past its mask edge to blend with the surroundings. Raise it if you're getting hard borders.
  • restore_latent (default on) - after each region samples, it restores everything outside that region's mask back to the base latent, so region sampling can't dump stray noise into the rest of the frame. Leave it on unless you have a reason not to.

The single output is a LATENT - feed it into a VAE Decode like any other sampler result.

One thing the README calls out and it's worth heeding: the sde and uni_pc samplers inject extra noise each step, so when a region uses them the node quietly applies a corrective sampler underneath. Not something you set, just don't be surprised the internals are doing work.

How to install it

Easiest path is ComfyUI Manager: open the Manager, search ComfyUI Impact Pack, hit Install, restart. Done.

Manual install:

cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack
cd ComfyUI-Impact-Pack
pip install -r requirements.txt

Run that pip inside the same Python environment ComfyUI uses (for the portable build that's ..\..\..\python_embeded\python.exe -m pip), then restart. Automatic install was dropped back in v7.6, so the Manager or the manual steps are the only routes now. First launch pulls a small SAM model into ComfyUI/models/sams - that's for other parts of the pack, not this node, and it's harmless.

Common issues & troubleshooting

The recurring one is a plain crash on execution, historically an error about calculate_sigmas_scheduler not existing - a version-mismatch between Impact Pack and ComfyUI core. The fix that's worked for people is boring: update Impact Pack to the latest version (and update ComfyUI while you're there). Regional sampling leans hard on core's sampler internals, so a stale pack against a newer ComfyUI, or the reverse, is the usual culprit.

If two regions still bleed into each other, that's an overlap and mask problem, not a bug - tighten your masks and lower overlap_factor. And note the README's own warning that RegionalSampler's parameter order changed in a past update, so any ancient example workflow you import may wire the seeds wrong; rebuild it rather than trusting old JSON.

CategoryImpactPack/Regional

Inputs (14)

NameTypeDefaultDescription
seedINT00–18446744073709550000Random seed to use for generating CPU noise for sampling.
seed_2ndINT00–18446744073709550000Additional noise seed. The behavior is determined by seed_2nd_mode.
seed_2nd_modeCOMBOapplication method of seed_2nd. 1) ignore: Do not use seed_2nd. In the base only sampling stage, the seed is applied as a noise seed, and in the regional sampling stage, denoising is performed as it is without additional noise. 2) Others: In the base only sampling stage, the seed is applied as a noise seed, and once it is closed so that there is no leftover noise, new noise is added with seed_2nd and the regional samping stage is performed. a) fixed: Use seed_2nd as it is as an additional noise seed. b) seed+seed_2nd: Apply the value of seed+seed_2nd as an additional noise seed. c) seed-seed_2nd: Apply the value of seed-seed_2nd as an additional noise seed. d) increment: Not implemented yet. Same with fixed. e) decrement: Not implemented yet. Same with fixed. f) randomize: Not implemented yet. Same with fixed.
stepsINT201–10000total sampling steps
base_only_stepsINT20–10000total sampling steps
denoiseFLOAT1.000–1The amount of noise to remove. This amount is the noise added at the start, and the higher it is, the more the input latent will be modified before being returned.
samplesLATENTinput latent image
base_samplerKSAMPLER_ADVANCEDThe sampler applied outside the area set by the regional_prompt.
regional_promptsREGIONAL_PROMPTSThe prompt applied to each region
overlap_factorINT100–10000To smooth the seams of the region boundaries, expand the mask set in regional_prompts by the overlap_factor amount to overlap with other regions.
restore_latentBOOLEANtrueAt each step, restore the noise outside the mask area to its original state, as per the principle of inpainting. This option is provided for backward compatibility, and it is recommended to always set it to true.
additional_modeCOMBOratio between..._sde or uni_pc and other special samplers are used, the region is not properly denoised, and it causes a phenomenon that destroys the overall harmony. To compensate for this, a recovery operation is performed using another sampler. This requires a longer time for sampling because a second sampling is performed at each step in each region using a special sampler. 1) DISABLE: Disable this feature. 2) ratio additional: After performing the denoise amount to be performed in the step with the sampler set in the region, the recovery sampler is additionally applied by the additional_sigma_ratio. If you use this option, the total denoise amount increases by additional_sigma_ratio. 3) ratio between: The denoise amount to be performed in the step with the sampler set in the region and the denoise amount to be applied to the recovery sampler are divided by additional_sigma_ratio, and denoise is performed for each denoise amount. If you use this option, the total denoise amount does not change.
additional_samplerCOMBO1) AUTO: Automatically set the recovery sampler. If the sampler is uni_pc, uni_pc_bh2, dpmpp_sde, dpmpp_sde_gpu, the dpm_fast sampler is selected If the sampler is dpmpp_2m_sde, dpmpp_2m_sde_gpu, dpmpp_3m_sde, dpmpp_3m_sde_gpu, the dpmpp_2m sampler is selected. 2) Others: Manually set the recovery sampler.
additional_sigma_ratioFLOAT0.300–1Multiplier of noise schedule to be applied according to additional_mode.

Outputs (1)

NameTypeDescription
LATENTLATENTresult latent