Nodes/ComfyUI Impact Pack/Assemble (SEGS list)
ComfyUI Node Runs on cloud

Assemble (SEGS list)

Putting the SEGS List Back, In the Groups It Came In

By ltdrdata·Created 4 years ago·Updated about 15 hours ago· 3,396
Assemble (SEGS list)
  • seg_header
  • seg_elt
  • SEGS

Every detour through SEGS manipulation ends the same way: you flattened a pile of detections into individual segments, poked at them, and now you need them to be SEGS again so a detailer can eat them. Assemble (SEGS list) is the rebuild step - and the reason it can rebuild correctly is that its counterpart left a return address on every piece.

The mechanism

Two inputs. seg_header is the list of SEGS headers that came out of Decompose (SEGS list). seg_elt is the list of individual elements, possibly edited, possibly filtered, possibly reordered. The node reads the origin recorded on every element, groups elements by which SEGS they originally belonged to, and emits one SEGS per header - a list where each item is the SEGS that particular group of elements came from.

That's the difference from plain AssembleSEGS, which piles everything into a single SEGS. Here the grouping is preserved, which matters if you decomposed a list of five SEGS (one per video frame, say) and want five SEGS back rather than one lump with five times the segments.

Both inputs are taken as lists, and the output is a list, so downstream nodes execute once per SEGS - which is exactly the behaviour you had before you decomposed. The round trip is meant to be invisible to the rest of the graph.

There's a fallback for when it isn't: if any element in seg_elt carries an origin that doesn't appear among the supplied headers, the node logs a warning and dumps all elements into a single SEGS keyed off the first header. That's a deliberately forgiving failure - you get a working SEGS instead of an exception - but it means a mis-wiring can slip past you as "my frames got merged" rather than an error dialog. If your per-frame SEGS turned into one giant SEGS, look for that warning in the console.

Inputs and outputs

  • seg_header - SEGS_HEADER, list. Take it from Decompose (SEGS list).
  • seg_elt - SEG_ELT, list. Also from Decompose (SEGS list), after whatever element-level editing you did.
  • Output: SEGS - a list, one per header.

The header supplies the image dimensions the SEGS claims, so it isn't cosmetic - a header from a 1024×1024 pass paired with elements from a 512×512 pass will produce SEGS that lie about their size. Keep the pair together.

Where this fits in a real graph

The pattern is: list of SEGS → Decompose (SEGS list) → per-element work (Filter, Edit SEG_ELT, From SEG_ELT for inspection, Dilate Mask (SEG_ELT)) → Assemble (SEGS list) → detailers or SEGSPaste.

Why you'd want that rather than per-SEGS subgraphs: because element-level nodes work on one element at a time and ComfyUI will happily run them once for each item of the list, so you get "do X to every segment of every SEGS" without duplicating anything. Sorting or relabelling across SEGS boundaries is the other natural job - the kind of thing SEGS Assign (label) does within one SEGS but can't do across a list.

The pack files this family as SEGS_ELT Manipulation and calls it experimental. Take that literally: the nodes do what they say, but they're sharp-edged, and the wildcard typing means a mismatch sometimes surfaces as a validation message rather than a clear "wrong input" error.

Install

In Impact Pack, category ImpactPack/Util.

cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack
cd ComfyUI-Impact-Pack
pip install -r requirements.txt

Windows portable: ..\..\..\python_embeded\python.exe -m pip install -r requirements.txt, then restart. Manager users search ComfyUI Impact Pack. First run creates impact-pack.ini in the pack folder and downloads the default SAM checkpoint into models/sams unless an empty file named skip_download_model exists in custom_nodes.

Practical warnings

Empty seg_elt is a real possibility - a filter upstream can drop everything - and reassembling zero elements for a header gives you an empty SEGS, which most nodes tolerate and a few don't. If a detailer suddenly reports nothing to do, Count Elts in SEGS is the cheapest way to check you're not reassembling air.

And don't try to be clever with the headers: passing your own fabricated header or reusing one from a different decompose run is the fastest route to the fallback path and merged output. Feed the node exactly the two lists its sibling produced.

CategoryImpactPack/Util

Inputs (2)

NameTypeDefaultDescription
seg_headerSEGS_HEADER—
seg_eltSEG_ELT—

Outputs (1)

NameTypeDescription
SEGSSEGS—