Nodes/ComfyUI-BFSNodes/BFS Video Segment Picker (SAM 3)
ComfyUI Node

BFS Video Segment Picker (SAM 3)

BFS Video Segment Picker (SAM 3): pick who to replace in a video or in a set of keyframes.

By alisson-anjos·Created 8 months ago·Updated a day ago· 137
BFS Video Segment Picker (SAM 3)
  • image
  • sam3_model
  • sam3_clip
  • normals
  • hybrid_base
  • pose_keypoint
  • molmo_clip
  • masks
  • marked
  • overlay
  • report
  • hybrid
◄conceptsperson, animal►
◄threshold0.40►
◄max_per_concept8►
◄min_area0.002►
◄mark_color#FF00FF►
◄mark_opacity0.30►
◄selection{}►
◄tracktrue►
◄normals_conventionnormal_directx►
◄mark_stylenormal map (needs normals)►
◄hybrid_grow0.08►
◄strip_frames16►
◄free_afterunload all models from the GPU►
◄pose_regionconvex hull►
◄pose_gray_opacity1.00►
CategoryBFS/Mask

Inputs (22)

NameTypeDefaultDescription
imageIMAGEThe frames: the Keyframe Planner's source_frames or a short clip (at most 32).
sam3_modelMODELSAM 3.1: MODEL of a Load Checkpoint node with sam3.1_multiplex_fp16.safetensors.
sam3_clipCLIPSAM 3.1: CLIP of the same Load Checkpoint node; turns the concepts and Find texts into SAM prompts.
conceptsSTRINGperson, animalWhat the automatic pass looks for, comma separated (one SAM 3 text prompt each), e.g. person, animal, car, chair. Empty = no automatic pass, only what you add.
thresholdFLOAT0.400.05–0.95SAM 3 detection score threshold: lower finds more (and more false hits).
max_per_conceptINT81–32Most objects one concept or text prompt can return.
min_areaFLOAT0.0020–0.5Automatic objects smaller than this share of the image are dropped.
mark_colorSTRING#FF00FFTint of the selection in the marked output (hex).
mark_opacityFLOAT0.300–1How strongly the marked output tints the selection (0.3 = the Colored Mark default).
selectionSTRING{}Set by the panel: the selection on each frame.
trackBOOLEANtrueFrames without a selection take the nearest selected frame's mask, tracked with SAM 3.
normalsoptIMAGEOptional: MoGe normals of the same frames (Run MoGe Inference -> Render MoGe Geometry, a normal mode). With it the node also returns the normal-map hybrid guide.
normals_conventionoptCOMBOnormal_directxThe Render MoGe Geometry output mode the normals come from.
hybrid_baseoptIMAGEOptional: the hybrid output of another Video Segment Picker, to add this subject on top (one picker per subject).
pose_keypointoptPOSE_KEYPOINTOptional: DWPose Estimator keypoints of the same frames (body + hands + face), for mark_style 'openpose + face'.
molmo_clipoptCLIPOptional: Molmo2 as H3 encoder. It sees the whole video, finds the picked person again after camera cuts (describe -> track) and SAM 3.1 segments them there from Molmo's point.
mark_styleoptCOMBOnormal map (needs normals)How each subject is drawn in the hybrid output, always in its color: the normal map, the DWPose skeleton with the face, or texture-free alternatives that need no MoGe (flat, blur, pixelate, gray detail, edges). With a style that needs no normals, 'hybrid' works without the normals input.
hybrid_growoptFLOAT0.080–0.5Margin around the subject in the hybrid guide, relative to its size (normal map: 0.04-0.12; openpose: 0.08-0.18 around the person's convex hull).
strip_framesoptINT162–32How many frames the panel shows to pick on (SAM segments each one): fewer is faster.
free_afteroptCOMBOunload all models from the GPUAfter the node: free the GPU for the next nodes (H3). 'all models' also unloads H3 / the text encoder left from the last generation (they load again when needed). Clearing the caches also frees RAM, but the next run segments and tracks again. Before MoGe / DWPose / Molmo2 run (only on Propagate) every model is unloaded anyway, so a second run does not run out of memory.
pose_regionoptCOMBOconvex hullopenpose mark: the gray region around each subject. The convex hull (with hybrid_grow margin) hides the original body shape (the new one stays free); the outline follows the person (less background hidden, but the original silhouette shows).
pose_gray_opacityoptFLOAT1.000–1openpose mark: how opaque the gray region is (1.0 = fully hidden). Lower lets the background show through, but also the original person (clothes, body), which the result may then copy.

Outputs (5)

NameTypeDescription
masksMASKOne mask per frame: the person to replace.
markedIMAGEEvery frame with the person tinted (mark_color, mark_opacity).
overlayIMAGEThe strip frames with all objects found, numbered.
reportSTRINGJSON per frame: picked by hand, tracked from frame N, or empty.
hybridIMAGEWith normals: the frames (or hybrid_base) with this subject drawn as its tinted normal map; else hybrid_base or the frames.