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

RegionalSamplerAdvanced

Different prompts in different parts of one image, by step

By ltdrdata·Created 3 years ago·Updated 4 months ago· 3,242
RegionalSamplerAdvanced
  • latent_image
  • base_sampler
  • regional_prompts
  • LATENT
add_noisetrue
noise_seed0
steps20
start_at_step0
end_at_step10000
overlap_factor10
restore_latenttrue
return_with_leftover_noisefalse
additional_moderatio between
additional_sampler
additional_sigma_ratio0.30

Regional sampling is how you tell one image "put this on the left and that on the right" and have it actually stick. You define a mask per region and a prompt (and sampler) per region, and the sampler paints each area with its own conditioning. RegionalSamplerAdvanced is the step-controlled version of Impact Pack's RegionalSampler - same idea, but you drive it with explicit start/end steps instead of a single denoise value, which is what you want when you're layering it into a bigger multi-stage sampling schedule.

The thing that makes Impact Pack's regional sampling distinct from just masking two generations together: per the README, "unlike TwoSamplersForMask, sampling for each region is applied during each step." The regions co-develop rather than one finishing before the other starts, so they blend at the boundaries instead of colliding.

How it works

You build REGIONAL_PROMPTS upstream (each is a mask plus a sampler, made with the RegionalPrompt node), hand them to this node along with a base sampler and a starting latent, and it runs the schedule: at each step the base sampler samples the whole frame, then each region's bound sampler samples its masked area. Two controls keep it clean - overlap_factor blends each region into the area outside its mask, and restore_latent, per the README, restores "the areas outside the mask to the base latent, preventing additional noise from being introduced outside the mask during region sampling."

The inputs that matter

  • base_sampler (a KSAMPLER_ADVANCED) and regional_prompts - the base pass and the per-region prompt/sampler bundles. The core wiring.
  • latent_image - what you're sampling.
  • steps, start_at_step, end_at_step - the step schedule, which is the whole reason to use the "Advanced" variant over the plain one.
  • overlap_factor (default 10) - region-to-surroundings blend.
  • restore_latent (default true) - keep outside-mask areas pinned to the base; leave it on unless you have a specific reason.
  • add_noise, noise_seed, return_with_leftover_noise - noise control for chaining passes.

The additional_mode / additional_sampler / additional_sigma_ratio inputs exist for a specific reason the README spells out: the sde and uni_pc samplers inject extra noise each step, so the node applies an additional corrective sampler (dpmpp_fast or dpmpp_2m) to keep regions stable. Leave them at defaults unless you're chasing that interaction. Output is a LATENT - VAE-decode it as usual.

How to install it

ComfyUI Manager: search ComfyUI Impact Pack, install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack, install requirements into ComfyUI's Python (pip install -r requirements.txt, or ..\..\..\python_embeded\python.exe -m pip install -r requirements.txt on Windows portable), restart. No auto-install since v7.6. A small SAM model downloads to ComfyUI/models/sams on first run. Regional prompts also pair well with the Inspire Pack, so many regional workflows want it installed too.

Common issues

A cryptic comfy.samplers error on run. This is the recurring one users hit with the RegionalSampler family - errors like module 'comfy.samplers' has no attribute 'calculate_sigmas_scheduler' mean your Impact Pack and ComfyUI core versions are out of sync. This pack pins hard to specific ComfyUI versions (the README is wall-to-wall version notices). Update both to current and it clears; downgrading one to match the other also works in a pinch.

Parameter order changed under you. The README flags that a past RegionalSampler update reordered parameters and broke old graphs. If you loaded an old workflow and it misbehaves, re-check the inputs rather than assuming the node is broken.

Regions bleed into each other. Tune overlap_factor down for crisper boundaries, and keep restore_latent on so region sampling doesn't leak noise outside its mask.

CategoryImpactPack/Regional

Inputs (14)

NameTypeDefaultDescription
add_noiseBOOLEANtrueWhether to add noise
noise_seedINT00–18446744073709550000Random seed to use for generating CPU noise for sampling.
stepsINT201–10000total sampling steps
start_at_stepINT00–10000The starting step of the sampling to be applied at this node within the range of 'steps'.
end_at_stepINT100000–10000The step at which sampling applied at this node will stop within the range of steps (if greater than steps, sampling will continue only up to steps).
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.
return_with_leftover_noiseBOOLEANfalseWhether to return the latent with noise remaining if the noise has not been completely removed according to the noise schedule, or to completely remove the noise before returning it.
latent_imageLATENTinput latent image
base_samplerKSAMPLER_ADVANCEDThe sampler applied outside the area set by the regional_prompt.
regional_promptsREGIONAL_PROMPTSThe prompt applied to each region
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