SEGS Wildcard Prompt
A different prompt for every detected segment
- prompt
Wildcards - the {a|b|c} dynamic-prompt syntax that Impact Pack made famous - are usually a per-image thing: the whole image picks one option and you move on. XJSegsWildcardPrompt does something more interesting: it parses wildcard syntax per segment, so segment 0 gets one prompt, segment 1 gets the next, and so on. It's the bridge between "detector found N things" and "each of those things gets its own tailored prompt."
The node understands a genuinely useful slice of Impact Pack's wildcard grammar. The headline feature is [SEP]: you write your prompts separated by [SEP] markers, and the node hands back the prompt matching your index, cycling if the index exceeds the count. That's how you map segment index → prompt. On top of that:
- Ordering modes -
[ASC],[DSC],[ASC-SIZE],[DSC-SIZE]control prompt order, and[RND]shuffles (seeded by theseedinput, so it's reproducible). [SEP:R]and[SEP:SEED]- assign a random or fixed seed to a specific prompt's{a|b|c}expansion, so the same option list gives different results per segment.[LAB]mode - map prompts to labels:[LAB][face]promptA[hand]promptB[ALL]shared. Pair it with thelabelinput (feed it thelabeloutput of SEGS Extractor) and segments get prompts by what they are, not just by position.- Option expansion -
{a|b|c}basics, weighted{3::a|b}, and multi-select{2$$,$$a|b|c}.
The interface:
wildcard_text- the multiline wildcard string.index- the segment index (0-based).label- optional; required for[LAB]mode.seed- optional; drives[RND]shuffling and random expansions.- Output:
prompt, the resolved STRING for that segment.
Where it earns its place: the per-region detail workflow. Loop segments through this node (index = the loop counter), get a per-face or per-object prompt, and feed it to the detailer's positive conditioning. That's the difference between detailing every face with the same generic prompt and giving the main subject "portrait of a woman, detailed eyes" while the person in the back gets "candid, motion blur." The [LAB] mode is the more robust route if your detector's labels are reliable - it survives segment order changing between runs.
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 use ComfyUI Manager and search "ComfyUI-XJNodes". No models, empty requirements.txt. The grammar it parses comes from Impact Pack's wildcard world, so familiarity with that syntax pays off here.
Caveat: this is a personal-use pack with a thin footprint, and the node implements a subset of Impact Pack's grammar - don't assume every wildcard feature from other tools works here. What's implemented is documented in the source and covers the common cases well.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| wildcard_text | STRING | — | |
| index | INT | 00–10000 | — |
| labelopt | STRING | — | |
| seedopt | INT | 00–4294967295 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |