Nodes/ComfyUI-BrainDead/BD Parts Refine
ComfyUI Node

BD Parts Refine

Cluster tagged masks by pairwise IoU. Per cluster, pick a canonical tag (shortest label = most general) and merge geometry (union or keep_largest). Use to dedupe SAM3 outputs from synonymous VLM descriptors (e.g. 'shoe' + 'sneaker' + 'left shoe' → one entry). Optional max_parts caps the kept count by area (largest first). Optional debug overlay paints each refined mask with a unique color.

By BizaNator·Created 7 months ago·Updated 16 days ago· 14
BD Parts Refine
  • masks
  • image
  • refined_masks
  • refined_labels
  • debug_overlay
  • summary
labels
iou_threshold0.70
merge_strategyunion
max_parts0
min_pixels64
output_debug_vizfalse
Category🧠BrainDead/Segmentation

Inputs (8)

NameTypeDefaultDescription
masksMASKMASK batch (B, H, W) — one per input prompt.
labelsSTRINGParallel labels, one per line. Auto-named part_NN if shorter than batch.
iou_thresholdFLOAT0.700–1Masks with IoU above this merge into one cluster. Lower = more aggressive dedup. 0.7 is a good starting point.
merge_strategyCOMBOunionunion: pixel-wise max across cluster (more inclusive). keep_largest: pick the cluster member with the most pixels (cleaner edges).
max_partsINT00–64Cap total refined parts (largest area kept). 0 = no cap.
min_pixelsINT641–10000000Drop masks smaller than this before clustering. Filters noise/false-positives from low-confidence prompts.
imageoptIMAGEOptional source IMAGE — required if output_debug_viz=True.
output_debug_vizoptBOOLEANfalseRender a color-coded overlay of the refined masks on the source image. Requires `image` wired.

Outputs (4)

NameTypeDescription
refined_masksMASK
refined_labelsSTRING
debug_overlayIMAGE
summarySTRING