SAM2 Image Inference (AnotherUtils)
SAM2 Image Inference — point at something and get a mask, no extra node packs required
- image
- model
- bboxes
- MASK
SAM2 is the segment-anything model that cuts objects out of images from a point or a box. In ComfyUI, getting it running usually means installing a heavyweight node pack with a pile of dependencies and hoping nothing conflicts. AnotherSAM2Inference takes a different road: it runs a SAM2 implementation bundled inside this pack, with the model weights auto-downloaded on first use. Give it a model, an image, and some prompts - points, boxes, or both - and you get a mask back.
That "no giant dependency stack" angle is the whole selling point. The pack's README is explicit about it: the inference suite runs locally using internal implementations that mimic the official SAM2 code, precisely so you don't have to go wading into dependency hell to segment an image. In a custom-node ecosystem where dependency conflicts are the number one source of pain, that's a real advantage.
How it works
The workflow has three pieces. First AnotherLoadSAM2 picks a model (the sam2_hiera_tiny through sam2_hiera_large checkpoints) - if it's not on disk, the node downloads it into ComfyUI/models/sam2 automatically. That loader hands you an ANOTHER_MODEL object. Then you feed that model plus an image into this node, along with prompts:
points_pos(STRING) - JSON array of{"x": ..., "y": ...}positive points (things to include).points_neg(STRING) - negative points (things to exclude).bboxes(BBOX) - bounding boxes as an alternative or complement to points.
The node runs SAM2's zero-shot prediction, and here's a useful behavior: if SAM2 returns multiple predicted masks, they're merged into one combined mask with an OR operation. So a single run can cut out several objects at once and hand you one unified mask. It also processes a batch element by element, so multiple images in means multiple masks out.
Inputs and outputs
The two required inputs are image (IMAGE) and model (ANOTHER_MODEL from AnotherLoadSAM2). The prompts are optional - you can segment from points, boxes, or both. The single output is MASK, ready for inpainting, compositing, or mask math.
The prompt formats line up with the rest of the pack: PointCollectorSAM2 produces the point JSON, AnotherBBoxToPoints and SEGStoBBox produce the boxes. It's one consistent pipeline.
Installing it
Part of the AnotherUtils pack:
cd ComfyUI/custom_nodes
git clone https://github.com/marcoc2/ComfyUI-AnotherUtils.git
Restart ComfyUI, or install via ComfyUI Manager (search "AnotherUtils"). On the first run of AnotherLoadSAM2, the model downloads itself into models/sam2 - you don't hunt for weights. The download needs a working internet connection and a bit of patience for the larger checkpoints.
Gotchas
The merged-mask behavior cuts both ways. If you want each object as a separate mask for individual processing, this node isn't giving you that - you'd want per-object handling elsewhere. Also, the "internal implementation" means you're on the pack author's copy of the SAM2 logic; it works, but you don't get the full feature surface or version control of the official package.
First-run model downloads are the most common stumble: if the node errors on a fresh install, it's usually the checkpoint still downloading or a failed fetch - check your connection and that models/sam2 has space. The small tiny model is the right place to start; it's enough to verify the pipeline before committing to the big one.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model | ANOTHER_MODEL | — | |
| points_posopt | STRING | [] | — |
| points_negopt | STRING | [] | — |
| bboxesopt | BBOX | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |