Files
Antonio Cordero Balcazar 2eaf2b05fe * Improved detection of model class and some new models.
* Fixed seed size in ComfyUI to account for frontend limits.
* Better wildcard key validation.
* Some refactoring.
2026-07-20 15:45:04 +02:00

108 lines
5.4 KiB
Markdown

# Prompt PostProcessor for Stable Diffusion WebUI and ComfyUI
The Prompt PostProcessor (or PPP, formerly known as "sd-webui-sendtonegative"), is an extension designed to process the prompt in several ways. This extension is compatible with:
* [ComfyUI](https://github.com/comfyanonymous/ComfyUI)
* [Forge Neo](https://github.com/Haoming02/sd-webui-forge-classic/tree/neo)
* [SD.Next](https://github.com/vladmandic/sdnext)
* [Forge Classic](https://github.com/Haoming02/sd-webui-forge-classic/tree/classic)
* [Forge](https://github.com/lllyasviel/stable-diffusion-webui-forge)
* [reForge](https://github.com/Panchovix/stable-diffusion-webui-reForge)
* [AUTOMATIC1111 Stable Diffusion WebUI](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
* ...and probably other forks
These are some features:
* Process wildcards. Compatible with the Dynamic Prompts extension.
* Sending parts of the prompt to the negative prompt (the original function of the extension). This allows for useful tricks when using wildcards since you can add negative content from choices made in the positive prompt.
* Define model variants (pony, illustrious, ...) and have them set as system variables along with the current model, to detect which one is being used.
* Set and modify user variables.
* Set content based on conditions (like the system/user variables).
* Map extranetworks (LoRAs) depending on conditions (like the loaded model/variant). This allows you to add "virtual" LoRAs to the prompt that will be translated to the correct one.
* Clean up the prompt of unnecessary separators or spaces.
* Combinatorial mode.
> [!NOTE]
> When used in an *A1111* compatible webui, the extension must be loaded after any other extension that modifies the prompt (like another wildcards extension).
>
> Usually extensions load by their folder name in alphanumeric order, so if the extensions are not loading in the correct order just rename this extension's folder so the ordering works out.
>
> When in doubt, just rename this extension's folder with a "z" in front (for example) so that it is the last one to load, or manually set such folder name when installing it.
If the extension runs before others, like Dynamic Prompts, and the "Process wildcards" option is enabled, the wildcards will be processed by PPP and those extensions will not get them. If you disable processing the wildcards, and you intend another extension to process them, you should keep the "What to do with remaining wildcards?" option as "ignore".
Notes:
1. Other than its own commands, it only recognizes regular *A1111* prompt formats. So:
* **Extra networks**: `<kind:model...>`
* **Attention**: `[prompt] (prompt) (prompt:weight)`
* **Alternation**: `[prompt1|prompt2|...]`
* **Scheduling**: `[prompt1:prompt2:step]`
* **BREAK**: `prompt1 BREAK prompt2`
* **Composable Diffusion**: `prompt1:weight1 AND prompt2:weight2`
*ComfyUI* only supports natively the attention using parentheses, so the ones with the brackets will be converted. The other constructs are not natively supported but some custom nodes implement them. For example:
[ComfyUI_smZNodes](https://github.com/shiimizu/ComfyUI_smZNodes)
I also recommend a node to add LoRAs from the prompt, like:
[LoRA Tag Loader for ComfyUI](https://github.com/badjeff/comfyui_lora_tag_loader)
In *SD.Next* that means only the *A1111* or *Full* parsers. It will warn you if you use the *Compel* parser.
Does not recognize tokenizer separators like `TE2:` and `TE3:`, so sending to negative prompt from those sections of the prompt will not add them in the corresponding section of the negative prompt.
2. It recognizes wildcards in the `__wildcard__` and {choice|choice} formats (and almost everything that [Dynamic Prompts](https://github.com/adieyal/sd-dynamic-prompts) supports).
3. It does not create *AND/BREAK* constructs when moving content to the negative prompt.
## Installation
On *ComfyUI*:
1. Go to Manager > Custom Nodes Manager
2. Search for "Prompt PostProcessor" and install or click Install via Git URL and enter <https://github.com/acorderob/sd-webui-prompt-postprocessor>
3. Restart
On *A1111* compatible webuis:
1. Go to Extensions > Install from URL
2. Paste <https://github.com/acorderob/sd-webui-prompt-postprocessor> in the URL for extension's git repository text field
3. Click the Install button
4. Restart the webui
On *SD.Next* I recommend you to disable the native wildcard processing and use the old UI.
## Configuration
See the [configuration documentation](docs/CONFIG.md).
## Usage
See the [syntax documentation](docs/SYNTAX.md).
## Cookbook
See the [cookbook](docs/COOKBOOK.md) for interesting usages.
## Tools
### User tools
* `tools/convert_styles.py`: converts A1111 or SD.Next styles into a wildcards file.
* `tools/check_loras.py`: checks for valid loras inside wildcards.
### Dev tools
* `dev/compare_models.py`: checks for new supported models in hosts.
## Contributing
To develop, I suggest doing so with the extension isolated from the host UI (you can use a symlink to test it in the UI), and with its own virtual environment (venv or .venv), so the tests work and can be debugged properly.
## License
MIT
## Contact
If you have any questions or concerns, please start a thread in the discussions. For bug reports and feature requests open an issue.