Nodes/ComfyUI-BrainDead/BD Parts Builder
ComfyUI Node

BD Parts Builder

Build a PARTS_BUNDLE from per-prompt SAM3 masks (preferred) or Sapiens2 labels. Each part gets its own RGBA crop + bbox + tag + per-part depth (when depth_image wired). Primary output is `parts` for the BD_Parts* pipeline. Auxiliary outputs (image_batch, label_list, bbox_list) feed BD_BulkSave / ImageUpscaleWithModel for batch-only workflows. Selection presets only match Sapiens2's 29-class taxonomy. For SAM3 source use 'all' or 'specific'.

By BizaNator·Created 7 months ago·Updated 16 days ago· 14
BD Parts Builder
  • image
  • sapiens2_labels
  • masks
  • depth_image
  • combined_mask
  • image_batch
  • label_list
  • bbox_list
  • parts
selection_modeall
padding_pixels5
output_sizenative
square_padpad_to_square
backgroundalpha
min_pixels64
mask_labels
selection_list
output_size_custom1024
background_hex#888888
Category🧠BrainDead/Segmentation

Inputs (15)

NameTypeDefaultDescription
imageIMAGE
selection_modeCOMBOallall = every class except Background. clothing/bodyparts = curated subsets (Sapiens2 taxonomy). specific = whitelist from selection_list.
padding_pixelsINT50–512Pixels of padding around each part's bbox (in source resolution).
output_sizeCOMBOnativenative = keep crop's natural size (per-part may differ — batched by padding to common max). 512/1024/2048 = scale longest side, preserve aspect.
square_padCOMBOpad_to_squarepad_to_square: center each crop in NxN canvas (uniform aspect, ideal for upscaler batching and T3D). none: keep aspect, pad batch to the rectangular common-bbox of all crops.
backgroundCOMBOalphaalpha = RGBA, mask baked to alpha channel (best for T3D). white/black/hex = composite onto solid background (best for 2D pipeline).
min_pixelsINT641–10000000Drop parts whose mask area is fewer than this many pixels.
sapiens2_labelsoptSAPIENS2_LABELSPreferred input from Sapiens2Segmentation. Carries class_ids tensor + part name taxonomy. When wired, `masks` and `mask_labels` are ignored.
masksoptMASKGeneric MASK batch (B,H,W) — one mask per class. Used when sapiens2_labels is not wired (e.g. SAM3 multi-prompt output).
mask_labelsoptSTRINGParallel labels for `masks` (newline or comma separated). Auto-named part_00, part_01, … if shorter than the batch.
depth_imageoptIMAGEOptional depth IMAGE (e.g. from BD_Lotus2Predict.raw_linear). When wired, each part's depth_median is computed from the median depth value within its mask region (used by Composite for back-to-front sort), AND the cropped depth map for that part is stored in the parts dict so Export can save it. Use the raw_linear output (0=near, 1=far) for proper sorting.
combined_maskoptMASKOptional silhouette mask. When wired, every per-class/per-prompt mask is intersected with this before bbox + crop. Sources: • BD_SAM3MultiPrompt.combined_mask — drops pixels removed by negatives / vote / color filter. The authoritative final layer. • Sapiens2SegmentationAdvanced.foreground_mask — confines per-class to body. WARNING: do NOT wire an inverted mask here. If SAM3's invert_combined=True is set upstream, you'll get the BACKGROUND silhouette — every real part will be zeroed and you'll see only a single full-image leftover.
selection_listoptSTRINGWhen selection_mode=specific: comma or newline separated label names to include (e.g. 'Left_Shoe,Right_Shoe,Upper_Clothing').
output_size_customoptINT102464–8192Used when output_size=custom.
background_hexoptSTRING#888888Hex color when background=hex. Accepts #RGB or #RRGGBB.

Outputs (4)

NameTypeDescription
image_batchIMAGE
label_listSTRING
bbox_listSTRING
partsPARTS_BUNDLE