Nodes/ComfyUI-BrainDead/BD Parts Underpaint
ComfyUI Node

BD Parts Underpaint

Inpaint the source image where each part was removed, revealing what is naturally visible underneath — skin under clothing, car interior under panels, background behind an object, etc. Companion to BD_PartsBatchEdit: use both together — BD_PartsBatchEdit → rebuilt part renders (each part redrawn cleanly) BD_PartsUnderpaint → base_image (source with all parts removed) Wire base_image into BD_PartsExport[base_image] so the rebuilt parts composite onto the clean bare surface. Two modes: per_part_sequential — one Qwen pass per part in remove_order. Each pass result feeds the next, progressively stripping layers. Outputs intermediate frames as image_batch. all_parts_combined — union all part masks, single Qwen pass. Faster but harder for Qwen to fill very large masked regions coherently.

By BizaNator·Created 7 months ago·Updated 16 days ago· 14
BD Parts Underpaint
  • parts
  • model
  • clip
  • vae
  • source_image
  • parts
  • base_image
  • image_batch
  • summary
modeper_part_sequential
prompt_templateRemove the {tag} from this image. Fill the region with whatever would naturally be visible underneath or behind the {tag} in this scene — skin, clothing, background surface, or interior. Preserve all surrounding pixels exactly.
prefill_modecolor_spread
latent_upscale_methodnearest-exact
target_pixels1024x1024
seed0
steps4
cfg1.0
sampler_nameeuler
schedulersimple
denoise1.00
model_typeqwen_edit
remove_order
all_parts_promptRemove all the highlighted parts from this image and reveal the complete underlying surface — bare skin, undergarments, interior, or background — as it would naturally appear with all parts absent.
context_extend_factor1.5
skip_tags
mask_dilate_pixels4
mask_blend_pixels4
latent_upscale_factor1.25
model_sampling_shift3.0
cfg_norm_strength0.85
tonemap_reinhard_multiplier2.0
target_pixels_custom1048576
negative_prompt
composite_modemask_region
full_image_passfalse
Category🧠BrainDead/Segmentation

Inputs (31)

NameTypeDefaultDescription
partsPARTS_BUNDLE
modelMODEL
clipCLIP
vaeVAE
source_imageIMAGEOriginal full-resolution source image (before any parts were removed). Required — this is what gets inpainted.
modeCOMBOper_part_sequentialper_part_sequential — one Qwen inpaint call per part, processed in remove_order (outer layers first). Each pass feeds the next so successive layers reveal beneath each other. Gives the most detailed per-layer result but takes N × Qwen inference time. all_parts_combined — union all part masks into one, single Qwen call. Faster. Best when parts don't overlap much. May struggle to inpaint very large masked areas coherently.
prompt_templateSTRINGRemove the {tag} from this image. Fill the region with whatever would naturally be visible underneath or behind the {tag} in this scene — skin, clothing, background surface, or interior. Preserve all surrounding pixels exactly.Prompt for per_part_sequential mode. {tag} is replaced with the part's label. Adjust for your domain: Characters: 'Remove the {tag} and show the garment or bare skin underneath' Vehicles: 'Remove the {tag} and show the interior/chassis beneath' Products: 'Remove the {tag} and reveal the underlying surface'
prefill_modeCOMBOcolor_spreadHow to fill the masked region BEFORE Qwen sees it: color_spread (DEFAULT) — cv2 Telea inpaint: fills from surrounding boundary colors. Gives Qwen a plausible color gradient to refine, which typically produces the most natural 'underneath' texture. nearest_neighbor — Voronoi spread from nearest outside pixel. Sharper color boundaries. Good for geometric shapes. neutral_gray — 50% gray fill. Safe baseline. white / black — flat fills. Black required for Qwen Inpaint LoRA (prompt must start with 'Inpaint the black areas.'). none — pass the raw crop as-is (Qwen sees existing occluders).
latent_upscale_methodCOMBOnearest-exactInterpolation for latent upscale.
target_pixelsCOMBO1024x1024Working resolution for each Qwen inpaint pass.
seedINT00–18446744073709550000
stepsINT41–1004 for Lightning LoRA, 8-20 for non-Lightning.
cfgFLOAT1.00–20
sampler_nameCOMBOeuler44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38
schedulerCOMBOsimple9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
denoiseFLOAT1.000–1
model_typeoptCOMBOqwen_editWhich edit model is wired in: qwen_edit — Qwen Image Edit (default). Uses VLM image tokens + reference_latents. Requires the Qwen Edit model stack (UNETLoader → Lightning LoRA → Inpaint LoRA). kontext_dev — Flux Kontext Dev (flux1-kontext-dev). Uses plain CLIPTextEncode + image_cond_latents. Load flux1-kontext-dev.safetensors with UNETLoader and its matching dual CLIP. flux_fill — Flux Fill Dev or any plain Flux inpaint model. Uses CLIPTextEncode + noise_mask only. Load flux1-fill-dev.safetensors.
remove_orderoptSTRINGComma or newline separated list of tags specifying which parts to remove and in what order (outer-to-inner). Missing = use bundle's dict order. Example for a clothed character: jacket, shirt, pants Tags not in this list that exist in the bundle are silently skipped ONLY if they aren't in the bundle. Unknown tags are ignored. Leave empty to process all parts in bundle order.
all_parts_promptoptSTRINGRemove all the highlighted parts from this image and reveal the complete underlying surface — bare skin, undergarments, interior, or background — as it would naturally appear with all parts absent.Prompt used in all_parts_combined mode (single inpaint call, all masks unioned). {tag} and {tags} are replaced with the comma-joined list of removed part labels.
context_extend_factoroptFLOAT1.51–3How much surrounding context to give Qwen around each part's bbox. 1.0 = crop exactly to part bbox. 1.5 = 50% larger crop so Qwen sees more neighboring skin/surface for better extrapolation. 2.0 = double. Higher = better context but smaller part gets larger canvas proportion.
skip_tagsoptSTRINGTags to skip entirely (csv or newline). Parts not in this list are still processed. Useful to skip hair, background, or accessory parts that shouldn't be removed before the underpaint.
mask_dilate_pixelsoptINT40–256Expand the inpaint region N pixels beyond the exact part boundary. Also controls the compositing zone — blending back uses the dilated mask so original object edges/halos never leak through. 4-8 for slight seam smoothing; 64-128 for aggressive background removal where outlines are still visible.
mask_blend_pixelsoptINT40–32Soft-edge feather when pasting the Qwen result back into the source. Prevents hard seams at the part boundary. 4-8 recommended.
latent_upscale_factoroptFLOAT1.251–2Upscale the encoded latent by this factor before KSampler (high-res-fix). 1.25 is a good default with the Lightning LoRA stack. 1.0 = no upscale.
model_sampling_shiftoptFLOAT3.00–20ModelSamplingAuraFlow shift. Required for Lightning LoRA + latent upscale. 3.0 from the standard recipe. 0.0 = disabled.
cfg_norm_strengthoptFLOAT0.850–2CFGNorm post-cfg function. 0.85 from recipe. 0.0 = disabled.
tonemap_reinhard_multiplieroptFLOAT2.00–10Reinhard tonemap on KSampler output before VAE decode. 2.0 from recipe. 0.0 = off.
target_pixels_customoptINT104857665536–4194304Custom pixel budget (used when target_pixels='custom').
negative_promptoptSTRINGNegative prompt (no effect at cfg=1.0).
composite_modeoptCOMBOmask_regionHow the edited crop is merged back into the scene: mask_region (DEFAULT) — paste only the masked region back onto the original; pixels outside the mask stay untouched. Correct for inpaint models (qwen_edit / flux_fill) whose noise_mask already kept the surround identical. full_crop — paste the model's ENTIRE edited crop (feathered only at the crop border). Use for full-image edit models (kontext_dev): removes objects cleanly with no leftover pixels outside the mask, and avoids the masked-patch misalignment/ghosting (doubling) you get when compositing a regenerated patch back onto the un-regenerated original. Rule of thumb: kontext_dev → mask_region (with full_image_pass on), qwen_edit/flux_fill → mask_region.
full_image_passoptBOOLEANfalseFeed the WHOLE image to the model each pass instead of a per-part crop. Instruction edit models (kontext_dev, qwen_edit) are designed to see the entire scene. Cropping to a part's bbox strips global context and makes them hallucinate fill that doesn't match the scene (e.g. a floating beach in the middle). Turn this ON for edit models. When ON, context_extend_factor is ignored. Combine with composite_mode=mask_region for clean object removal with zero drift outside the mask. Leave OFF only for a true masked inpaint model (flux_fill) where a focused crop is cheaper and correct. Note: per_part_sequential + full_image_pass runs a full-image generation per part (slower). all_parts_combined does it in a single pass.

Outputs (4)

NameTypeDescription
partsPARTS_BUNDLEPassthrough — unchanged PARTS_BUNDLE.
base_imageIMAGESource image with all processed parts inpainted away. Wire into BD_PartsExport[base_image] so rebuilt part renders composite onto this clean surface.
image_batchIMAGE(N, H, W, 3) batch of per-step intermediate frames for sequential mode. Frame 0 = after removing first tag, frame N-1 = base_image. Single frame for all_parts_combined.
summarySTRING