LC Detail Sorter (BETA) π’
Putting Your Characters in a Predictable Order
- sam3_masks
- image
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
What it is
Step two of the per-character detailer chain, and the smallest node in this pack: it takes LC Detail Finder's bundle, puts the matches in a defined order, and breaks them out into eight separate outputs.
No model, no download, no detection pass. It's a sort and a fan-out, which is why it earns its own node: somewhere in the chain "the face on the left" has to become "output 2", and if that mapping shifts between runs your per-character LoRAs land on the wrong people. Making the ordering explicit and visible - same numbering drawn on the preview - is the difference between a workflow you can debug and one you re-run until it looks right.
If you've wired Impact Pack's SEGS filters, the idea is familiar: detector, then an ordered filter, then a per-segment detailer. This is the ordered filter, with SAM 3 masks instead of SEGS.
How it works
Every match in the bundle has a centre of mass and an area, measured once by the Finder. pick chooses which of those becomes the sort key:
- left to right - 1 is the leftmost. The default, and the one most people want.
- right to left - 1 is the rightmost.
- top to bottom - 1 is the highest.
- largest first - 1 is the biggest, which in a normal photo means the closest.
The node then emits eight outputs, each of which is still an LC_SAM3_MASKS bundle - same type as the Finder's output, just carrying one match instead of all of them. Output 1 is the first in your chosen order, 2 the second, and so on. If there are fewer matches than slots, the extra outputs are empty rather than missing; the downstream node handles an empty bundle by passing the picture through untouched and saying so in the console.
Above eight, it just tells you: N found: only the first 8 have an output. Nine people in a group shot means the ninth gets no detail pass. That's a hard cap, not a setting.
Connect an image and you get the numbered preview: each match outlined in its own colour with its number drawn at its centre, in exactly the order the outputs count. That's the whole point - you read 3 off the picture, wire output 3 to that character's detailer, and stop guessing.
The inputs worth setting
Two required inputs, and that's the lot:
- sam3_masks - from LC Detail Finder.
- pick - the order (one of the four above).
Optional: image, purely for the numbered preview. It doesn't affect the masks at all - the outputs are the same with or without it. Wire it anyway; a preview you didn't wire is a preview you can't read at 11pm.
Outputs are 1 through 8, all LC_SAM3_MASKS. Each one wires to that character's LC Detailer For Each.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/lonecatone23/ComfyUI_LC_MaskMaker_nodes
# restart ComfyUI
Or search ComfyUI_LC_MaskMaker_nodes in ComfyUI Manager. Nothing to download for this node and nothing to configure - it's pure torch-side bookkeeping on masks you've already got. The pack's installer only tops up transformers and huggingface_hub if they're absent and never touches torch, numpy or Pillow, so it's a few seconds either way.
You do still need the rest of the chain for it to be useful: a Finder upstream, and a SAM 3 checkpoint (1.7 GB into models/sam3, downloaded once by the Finder) for that Finder to run.
Common issues
Output 4 does nothing. Four is empty - there were only three matches, or the sort put the one you wanted somewhere else. Look at the numbered preview rather than the console.
The numbering flips between runs. With a still image it shouldn't - the sort keys are stable. On video batches ordering is genuinely per-frame, so a character who walks across frame changes number; that's inherent to sorting by position.
Two characters swapped, so their LoRAs are on the wrong faces. Re-wire the outputs to the new order, or pick by position upstream instead: LC Character Detailer's in box mode uses LC Bounding Boxes and keeps a face with its character regardless of pose.
More than eight found. Narrow the prompt (face:4-style caps work in the Finder's prompt field) or accept that the extras go untouched. The cap isn't configurable.
That's the whole trick of automatic detailing, really: the loop is always the same crop-and-redraw, and the interesting decisions live in how you get the mask and how many of them you're willing to process.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| sam3_masks | LC_SAM3_MASKS | From LC Detail Finder. | |
| pick | COMBO | left to right | The order the outputs count in. left to right: 1 = the leftmost. largest first: 1 = the biggest (usually the closest). |
| imageopt | IMAGE | Optional: the picture, for the numbered preview. |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| 1 | LC_SAM3_MASKS | The SAM 3 mask of match 1 in the chosen order (empty when there are fewer). Wire it to that character's LC Detailer For Each. |
| 2 | LC_SAM3_MASKS | The SAM 3 mask of match 2 in the chosen order (empty when there are fewer). Wire it to that character's LC Detailer For Each. |
| 3 | LC_SAM3_MASKS | The SAM 3 mask of match 3 in the chosen order (empty when there are fewer). Wire it to that character's LC Detailer For Each. |
| 4 | LC_SAM3_MASKS | The SAM 3 mask of match 4 in the chosen order (empty when there are fewer). Wire it to that character's LC Detailer For Each. |
| 5 | LC_SAM3_MASKS | The SAM 3 mask of match 5 in the chosen order (empty when there are fewer). Wire it to that character's LC Detailer For Each. |
| 6 | LC_SAM3_MASKS | The SAM 3 mask of match 6 in the chosen order (empty when there are fewer). Wire it to that character's LC Detailer For Each. |
| 7 | LC_SAM3_MASKS | The SAM 3 mask of match 7 in the chosen order (empty when there are fewer). Wire it to that character's LC Detailer For Each. |
| 8 | LC_SAM3_MASKS | The SAM 3 mask of match 8 in the chosen order (empty when there are fewer). Wire it to that character's LC Detailer For Each. |