Dark Face Index Generator
Randomize which face goes where in Reactor — without hand-typing the index CSV
- STRING
Reactor (ComfyUI-Reactor-Nodes) is the post-generation face swapper that runs a pixel-level swap after the sampler - distinct from generative approaches like FaceID or PuLID. Its input_faces_index field takes a CSV string of face numbers, like 0,1,2, telling it which detected faces to swap with which sources. If you're generating group scenes with multiple faces, hand-typing that index every time is miserable. DarkFaceIndexGenerator writes it for you - and optionally shuffles it, so the same batch of friends shows up in a different order in every image.
How it works
You tell it how many faces are in the scene (number_of_faces), and it builds a plain sequence 0,1,2,...,N-1, joins it with commas, and hands you the CSV string. With randomize on (it is by default), it shuffles that sequence first using the seed, so the mapping between source faces and detected faces changes per generation.
The interesting knob is pad_to, and it exists because of a genuine Reactor quirk the source comments on: Reactor is "pretty dumb with faces" and needs an input face for every source face, even if some of those positions don't actually exist in the image - otherwise it won't swap any faces at all. So if you have 3 source faces but want a scene with 6 detected slots, set pad_to: 6 and the generator pads the sequence out to 0,1,2,3,4,5. That padding is why there are two randomize flags:
randomize(default on) - shuffle the sequence.randomize_after_padding(default on) - shuffle again after padding. If you leave this off, the padded filler indices stay at the tail, which is usually what you want when the fillers are decoys rather than real swaps.
What to set
number_of_faces(INT) - how many faces you're actually swapping.seed(INT, wireable) - reproducibility; same seed gives the same face order.pad_to(INT, optional) - pad the list to this length for scenes with more detected faces than sources.randomize/randomize_after_padding(BOOLEAN) - when the shuffle happens.
Output: a STRING like 2,0,1,3,4,5 - wire it into Reactor's input_faces_index input.
Install & gotchas
Installing Reactor is the heavier lift (it pulls in insightface and its pretrained ONNX models, and note the InsightFace models carry their own non-commercial licensing baggage). DarkFaceIndexGenerator itself is lightweight:
cd ComfyUI/custom_nodes
git clone https://github.com/darkpixel/darkprompts.git
Restart ComfyUI. Two things to keep in mind: the count must match your Reactor face list, or faces get misassigned silently - so when you change the number of source faces, change number_of_faces too. And the whole thing only matters if you actually want randomization; for a single face swap, 0 by hand is still faster than adding a node.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| number_of_faces | INT | — | |
| randomize | BOOLEAN | true | — |
| randomize_after_padding | BOOLEAN | true | — |
| seed | INT | 00–18446744073709550000 | — |
| pad_toopt | INT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |