Nodes/Image Processing Suite for ComfyUI/SEGS to SAM2 Points (JSON)
ComfyUI Node

SEGS to SAM2 Points (JSON)

Turn Impact Pack detections into SAM2 prompt points

By marcoc2·Created 2 years ago·Updated 5 months ago· 1
SEGS to SAM2 Points (JSON)
  • segs
  • json_points

SEGS to SAM2 Points (JSON) is the glue between two worlds: Impact Pack's detection output and SAM2's prompting format. It takes a SEGS input - the region-list type Impact Pack produces from YOLO/Ultralytics detectors - and converts every detected object's bounding box into a JSON array of center points like [{"x": 512, "y": 384}], which is exactly the format SAM2 video tracking nodes want for their coordinates_positive input. If you've ever tried to hand-wire detector boxes into SAM2 prompts, you know this saves a genuinely fiddly step.

The mental model: Impact Pack is the detection-and-detailing workhorse of the ecosystem - its SEGS structure is what FaceDetailer and friends chew on - but it speaks "bounding boxes in a custom struct." SAM2, on the other hand, wants point prompts (or box prompts) as plain coordinates. This node reads each SEG in the list, takes its (x1, y1, x2, y2) bbox, computes the center, and emits one point per detected object as JSON. One input, segs, one output, json_points, and it's deliberately about points - bbox centers - rather than full boxes, because SAM2's video tracking is commonly driven by single click points.

Where it shines: detector-to-SAM2 chains. Run a YOLO pass to find "person" or "object of interest," feed the resulting SEGS here, and hand the JSON to the pack's AnotherSAM2VideoAddPoints to initialize stateful segmentation tracking across a video - or to any SAM2 node that reads coordinate JSON. It's the "object found, now segment it precisely" bridge, and it pairs with the pack's own YOLO and SAM2 loaders to form a self-contained detect-then-segment pipeline that doesn't touch Impact Pack's inference nodes at all.

Two honest gotchas. First, the SEGS input type is Impact Pack's type - you need the SEGS to come from something that produces them (typically Impact Pack or a pack that emits its format), so "no external packs needed" applies to your dependency count, not to the data source. Second, empty detections are handled but not gracefully: if the detector finds nothing, the node returns "[]" and prints a blunt warning that SAM2 tracking will likely fail. That's fine - a warning is the right behavior - just don't mistake it for a bug in the node.

The bbox-centering is also worth a moment of thought: a detected box whose center lands on background rather than the subject (common with off-center crops) will feed SAM2 a bad prompt. If your detections look off, that's the first thing to suspect.

Install: ComfyUI Manager → search "AnotherUtils", or cd ComfyUI/custom_nodes && git clone https://github.com/marcoc2/ComfyUI-AnotherUtils, restart. No extra dependencies - it's pure Python converting one format to another.

CategoryAnotherUtils/SEGS

Inputs (1)

NameTypeDefaultDescription
segsSEGS

Outputs (1)

NameTypeDescription
json_pointsSTRING