SEGS Extractor
Crack a SEG open into image, mask, and coordinates
- seg
- image
- image
- mask
- x1
- y1
- x2
- y2
- label
- confidence
Impact Pack's SEG is a tidy little package: a cropped image, a mask, a confidence score, a crop region, a bounding box, and a label, all sealed in one namedtuple. It's a great format for moving detection data around, and a useless one for standard ComfyUI nodes, which want a bare IMAGE and a bare MASK. XJSegsExtractor is the crowbar. Feed it one SEG and it hands you the crop as an IMAGE, the mask as a MASK, plus the coordinates, label, and confidence as plain values.
The node also has a genuinely thoughtful feature hidden in its optional input: pass an image in and it crops that image using the SEG's stored crop region instead of using the SEG's own saved crop. The docstring spells out why - it enables iterative workflows where later segments should see the improvements from earlier ones. If you're building a loop where each pass refines the image and you want the next crop to be cut from the updated image, that's the difference between a working pipeline and one that keeps sampling from a stale frame.
The interface:
seg- one SEG (from SEGS Pick, typically).image- optional; if supplied, the crop comes from here instead of the SEG's stored crop.- Outputs, in order:
image,mask,x1,y1,x2,y2(the crop region, needed later by the stitcher),label,confidence.
That's a lot of wires, and honestly the four coordinates are the ones that feel wasted until you realize the Stitcher needs them to put the crop back. The label and confidence outputs are free metadata - wire them into a display node or use them for branching.
The intended flow: SEGS Pick → SEGS Extractor → process the image and mask in any standard nodes (an upscaler, a different sampler, whatever) → SEGS Stitcher puts the result back into the original image. That's the full manual detailer loop, built from pieces you understand, rather than trusting a black-box Detailer node. It's more work, and it's exactly what you want when the stock detailer isn't doing what you need.
Install is the pack-wide routine:
cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes
Restart ComfyUI, find it under XJNodes/segs, or install via ComfyUI Manager by searching "ComfyUI-XJNodes". No models, no pip dependencies (requirements.txt is empty), but it needs SEGS/SEG data, so Impact Pack has to be present to produce it.
Fair warning: personal-use pack, near-zero tutorials in the wild. But this node is the key to the most interesting pattern the pack enables, and the source is short enough to read if you want to know exactly what the mask conversion does.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| seg | SEG | — | |
| imageopt | IMAGE | — |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| x1 | INT | — |
| y1 | INT | — |
| x2 | INT | — |
| y2 | INT | — |
| label | STRING | — |
| confidence | FLOAT | — |