ComfyUI Node

SEG From SEGS

Keep regions 3 through 5 and stay a SEGS

By tom-m-2020·Created about a month ago·Updated 7 days ago· 1
SEG From SEGS
  • segs
  • segs
◄index0►
◄length1►

Detectors are optimistic. A face-detection pass on a group photo returns eight regions, three of which are a rock formation and someone's elbow, and the detailer will happily spend GPU time re-rendering all eight. SEG From SEGS is the blunt instrument for that: give it a SEGS set and a zero-based index plus a length, and it hands back a SEGS set containing only that contiguous range.

The important word is stay. This is not a converter. ComfyUI's SEGS is a tuple of a header (the source canvas dimensions) and a list of segment entries, and this node keeps the header, keeps the entries as the same objects, and returns the same type. So everything downstream - Impact's Detailer (SEGS), SEGSPaste, this pack's own SEGS nodes - still accepts it without any re-plumbing. Drop a list-picker in here instead and you'd have to reassemble a SEGS afterwards, which is exactly the kind of pointless step this node exists to skip.

Inputs and output

  • segs - the SEGS set.
  • index - zero-based start, default 0, 0 to 32768.
  • length - how many entries to keep, default 1, minimum 1.

Output: segs, the trimmed set.

The clamping is worth reading twice, because it decides whether this is a convenience or a trap. The index is capped at the last entry, then the length is capped so the range can't overrun. An empty input returns an empty set with the header intact - no error. Out-of-range values don't fail; they quietly give you the last region. If you were betting that a index=9 typo would blow up and tell you, it won't: it hands you region 8 and moves on. Check the entry count when you're first dialling a workflow in.

How you actually use it

It's the surgical counterpart to the pack's Reorder SEGS and Filter Tile SEGS. Reorder decides which order, Filter drops tiles with no unique content, and this one picks a specific slice - either because you know which regions you want after looking, or because you're running two passes with different prompts per region and need to split the set.

Finding the index you want is what Preview SEGS Regions is for: it labels every region with its index on a full-canvas preview, so "keep region 4" becomes something you can verify visually rather than count out in the node's hover preview.

The other shape: run the pass in chunks. Segments 0–3 with one prompt, 4–7 with another, then paste both. Two detailer runs, two conditioning sets, one composite. It's a lot of nodes to do what a per-region prompt table would do, but it's the way to do it with single-prompt nodes.

Install

Manager: search ComfyUI Utility Suite (publisher tom-m) → install → restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/tom-m-2020/ComfyUI-Utility-Suite

No models to download, no checkpoints; the pack's only dependency is opencv-python-headless and this node doesn't use it. It defines the SEGS socket as a duck-typed custom type matching Impact's shape, so it interoperates with Impact-Pack SEGS without requiring Impact itself - but you do need something that emits SEGS, whether that's a detector or this pack's MASK to Tile SEGS. The pack is built on ComfyUI's V3 node API, so keep ComfyUI current; an old build shows no Utility Suite/* nodes at all.

Troubleshooting

"expects SEGS shaped as (header, segment_entries)." Something upstream isn't a SEGS - often a plain list that looks similar on the canvas. The pack's List / Batch Inspector will tell you what you're actually holding.

I asked for 4 entries and got 3. The range ran past the end and was clamped. Same reason you can't get an error out of a bad index.

Empty output, no error. The input SEGS was empty, or had no entries after an upstream filter dropped them all - a common outcome when Filter Tile SEGS excludes everything on a blank canvas.

CategoryUtility Suite/SEGS

Inputs (3)

NameTypeDefaultDescription
segsSEGS—
indexINT00–32768—
lengthINT11–32768—

Outputs (1)

NameTypeDescription
segsSEGS—