xbhh txt随机抽取
Write ?color? ?animal? prompts and let the node fill in the blanks
- STRING
The fastest way to explore a prompt space isn't to hand-roll twenty variations - it's to write a pattern with blanks and let a node fill them in. Prompt Randomizer does exactly that: ?color? ?dog|cat? on the ?couch|floor? becomes "blue cat on the couch" one run, "red dog on the floor" the next. Inline options use | separators, and ?word? without a pipe means "look this up in a dictionary" - so ?color? pulls a random color from a JSON file you can edit. It's the classic prompt-variation tool, and it wires straight into batch samplers.
How it works
The node scans your prompt for ?...? groups, picks a random option from each (either inline after a |, or from the dictionary if the chosen word is a dictionary key), and replaces it - up to ten passes to handle nested tags. A few knobs shape the output:
- seed - set
-1for a fresh random seed every run, or a positive number for reproducible results. The node reports which seed it used viaused_seed, so you can lock in a good roll. - prompts_count - generate 1–100 random prompts at once, ideal for feeding a multi-seed or batch sampler.
- preserve_newlines - keep line breaks, or convert them to commas for single-line prompt style.
- clean_text - fixes punctuation, collapses double spaces, and - heads up - rewrites anime tag style:
1girlbecomes "one woman",1boybecomes "one man". If you're doing anime prompts, you'll want this off.
Outputs: modified_prompts (the filled-in text), selections (which words were chosen, as a comma string - nice for tracking), and used_seed.
The dictionary
On first run it creates prompt_dictionary.json in the pack's folder with starter categories: colors, animals, styles, lighting, moods, quality, backgrounds, weather. Edit that file to add your own categories - any key you use as a bare ?word? needs to exist there (or be an inline option). It's plain JSON, so you can add "?pose?" with a list of poses, "?camera?," whatever your workflow varies.
Installing it
Part of Pirog's Nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/Pirog17000/Pirogs-Nodes
pip install -r Pirogs-Nodes/requirements.txt
Or search "Pirog's Nodes" in ComfyUI Manager and restart. No extra dependencies.
Gotchas
The clean_text anime-term conversion surprises people - it's on by default and it will silently rewrite your tags. And if your dictionary JSON is malformed, the node falls back to its built-in defaults and logs a warning, so "my custom categories vanished" usually means a JSON syntax error. For batch use, keep prompts_count and the sampler's seed count in sync, or you'll get more prompts than images and lose the mapping. It's a simple node; the complexity lives in how you choose to feed it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — | |
| seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |