Nodes/SAMURAI Nodes for ComfyUI/SAMURAI Points Input
ComfyUI Node

SAMURAI Points Input

Click the object, right-click the background, and track it anyway

By takemetosiberia·Created 2 years ago·Updated 2 years ago· 43
SAMURAI Points Input
  • image
  • start_frame
  • POINTS
  • LABELS
  • START_FRAME
refresh_input0

Boxes are blunt instruments. If you want to track something thin or wiggly - a hand, a rope, a distant car - a rectangle drags in a lot of background along with it. SAMURAI Points Input is the point-based alternative to the pack's box node: instead of drawing a bounding box on the first frame, you click a few pixels that belong to the object, right-click a few that don't, and let SAM2's point prompting figure out the actual boundary. The mask then propagates through the whole clip in the Refine node.

Like its box sibling, this is a native OpenCV window, not an in-browser widget. It opens on the machine running ComfyUI, it blocks the queue until you finish, and it needs a display. If you're used to clicking points inside the ComfyUI canvas, adjust your expectations now.

How it works

The node pulls the frame at start_frame, opens a window, and attaches a mouse callback. Left click drops a positive point (drawn green), right click drops a negative one (drawn red). Positive means "this is the object", negative means "this is background" - the standard SAM point-prompt idiom, and it's exactly how you nudge the segmentation onto a hard object. Press Enter to finish; Esc cancels and clears your points so you can start over.

Both lists come back as numpy arrays: POINTS as [x, y] pairs and LABELS as 1s (object) and 0s (background).

Inputs and outputs

Three inputs, and you barely touch any of them:

  • image (required) - the video as an IMAGE batch, straight from a Load Video node.
  • start_frame - labeled with the author's own tooltip: "Select the starting frame for points input." Default 0.
  • refresh_input - tooltip: "Change this value to select new points." It's the re-click trigger.

Outputs are POINTS, LABELS, and START_FRAME. The first two feed the Refine node's points and labels inputs. One honest caveat from reading the shipped code: the Points node declares a START_FRAME output, but its get_points only actually returns points and labels, so that third output is unreliable. Keep start_frame at 0 on both this node and Refine, and don't build a workflow around starting mid-clip from here.

Installing it

Same story as the rest of the pack - a wrapper around upstream SAMURAI, not a self-contained install:

cd ComfyUI/custom_nodes
git clone https://github.com/takemetosiberia/ComfyUI-SAMURAI--SAM2-.git samurai_nodes

Copy your SAMURAI installation into samurai_nodes/, drop the sam2.1_*.pt checkpoints into samurai/sam2/checkpoints/, then pip install hydra-core omegaconf loguru. NVIDIA GPU with CUDA is required - the upstream code is CUDA-locked - and the README wants you on conda with ComfyUI running from a terminal. Nothing downloads itself.

Gotchas

  • Same popup-on-the-server problem as the box node. Headless or remote-only setup → no window, queue hangs forever.
  • On the Refine node, box and points are alternatives, not additions. Both prompt the same object, so wire either the box path or the points path - feeding both at once is asking for trouble.
  • Points are clicked at full resolution, and Refine won't rescale them if it downsizes your clip. Keep Refine's resolution at or above your video's longest side.
CategorySAMURAI

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
start_frameSTART_FRAME0Select the starting frame for points input
refresh_inputINT0Change this value to select new points

Outputs (3)

NameTypeDescription
POINTSPOINTS
LABELSLABELS
START_FRAMESTART_FRAME