Nodes/ComfyUI_KubaNodes/kubakub regions from sam3
ComfyUI Node

kubakub regions from sam3

Find facade parts automatically and get one named mask per object, ready for regions from masks. Uses SAM 3.1 (core SAM3 Detect) with text prompts (one line per kind of object, every hit its own mask), points from the KJNodes Points Editor (one object per positive point) and boxes. Points and boxes get a second pass on a crop at full resolution (detail), so small facade parts keep their edges. Optionally saves every mask as <name>.png into a project Masks folder.

By kubakubkub·Created 15 days ago·Updated 3 days ago· 9
kubakub regions from sam3
  • model
  • image
  • clip
  • bboxes
  • scope
  • boxes
  • masks
  • names
  • preview
  • report
◄prompts►
◄point_modeone region per point►
◄threshold0.50►
◄refine_iterations2►
◄detailtrue►
◄drop_groupstrue►
◄min_area64►
◄positive_coords—►
◄negative_coords—►
◄point_names►
◄save_folder►
◄overwritefalse►
Categorykubakub/2d/regions

Inputs (18)

NameTypeDefaultDescription
modelMODELSAM 3.1: Load Checkpoint with sam3.1_multiplex_fp16.
imageIMAGEThe matrix or render to segment (first image of a batch).
promptsSTRINGOne line per kind of object: 'name = text' or just 'text'. ':N' caps the hits (default 50). Every hit becomes a mask name_01, name_02 ... in reading order.
point_modeCOMBOone region per pointone region per point: each positive point is its own object (negative points apply to all). all points one region: core behaviour, one object from all points.
thresholdFLOAT0.500–1Text detection confidence.
refine_iterationsINT20–5SAM decoder refinement passes (core).
detailBOOLEANtruePoints and boxes: segment again on a crop around the object, so the 1008 px model input covers the object instead of the whole 4K frame.
drop_groupsBOOLEANtrueText: drop hits that cover two or more other hits of the same prompt (SAM often adds one mask for the whole row).
min_areaINT640–10000000Masks smaller than this (pixels) are dropped.
clipoptCLIPThe CLIP output of the same Load Checkpoint; needed for text prompts.
positive_coordsoptSTRINGPoints JSON (KJNodes Points Editor positive_coords, in image pixels or normalized).
negative_coordsoptSTRINGPoints that must stay outside (Points Editor negative_coords).
bboxesoptBBOXBoxes (Points Editor bbox, xyxy); one object per box.
point_namesoptSTRINGNames for the point objects in click order, then the boxes (bboxes first, then boxes). Missing: point_01.., box_01..
scopeoptMASKMasks are clipped to this; objects mostly outside it are dropped.
save_folderoptSTRINGOptional: write every mask as <name>.png (white on black, image size) into this folder, e.g. the project Masks folder.
overwriteoptBOOLEANfalseReplace existing PNGs of the same name in save_folder.
boxesoptBOUNDING_BOX[object Object]Boxes from core nodes (the bboxes output of SAM3 Detect, in image pixels); one object per box, added after the Points Editor boxes. Of a batch, the boxes of the first image are used.

Outputs (4)

NameTypeDescription
masksMASKOne mask per object (batch), same order as names.
namesSTRINGOne name per line; plug into regions from masks.
previewIMAGEThe found objects coloured and numbered over the image.
reportSTRINGEvery object with its size in pixels, how it was found and its score, plus notes (dropped hits, saved files).