feat: add ComfyUI-style prompt weighting via compel

- Support (word:weight), [word], ((nested)) syntax
- Support BREAK for conditioning chunking (.and() translation)
- Use CompelForSDXL (modern API, avoids deprecation)
- Add --raw flag to bypass weighting and fall back to plain encoding
- Update README with Prompt Syntax section and examples
- Add docs/comfyui-prompt-style.md with design doc
This commit is contained in:
Michele Rossi
2026-07-07 16:16:54 +02:00
parent 2cf58aaa5c
commit 9564202e6d
6 changed files with 355 additions and 22 deletions

View File

@@ -70,6 +70,7 @@ vnasset generate \
| `--cfg` | `4.5` | CFG scale |
| `--seed` | `0` | RNG seed (use `random` for random) |
| `--output` | `output.png` | Output path |
| `--raw` | `false` | Disable Compel prompt weighting (fall back to plain diffusers encoding) |
When `--seed` is `random`, a random seed is generated and recorded in the
metadata file.
@@ -154,18 +155,39 @@ implementation that avoids the SDPA dispatch entirely.
Tested with `torch 2.11.0+rocm7.2`. Newer ROCm nightlies (2.13+, 2.14+) may
cause GPU crashes. If you encounter segfaults, try matching this version.
## Prompt Compatibility
## Prompt Syntax
VNAsset uses standard diffusers SDXL encoding, which is equivalent to ComfyUI's
`BNK_CLIPTextEncodeAdvanced` with `token_normalization=none` and
`weight_interpretation=comfy` for plain comma-separated prompts.
VNAsset supports **ComfyUI-style prompt weighting** via the `compel` library.
ComfyUI-specific syntax is **not currently supported**:
- `(word:1.2)` — prompt weighting
- `BREAK` — conditioning chunking
### Weighting
If your prompts rely on these, you'll get different output than the ComfyUI
workflow. compel integration is planned for later.
| Syntax | Effect |
|--------|--------|
| `(word)` | Boost ×1.1 |
| `(word:1.5)` | Boost ×1.5 |
| `(word:0.6)` | De-emphasize ×0.6 |
| `[word]` | De-emphasize ×0.9 (shorthand) |
| `\(word\)` | Literal parentheses (escaped) |
```bash
vnasset generate \
--checkpoint models/novaAnimeXL_ilV190.safetensors \
--prompt "(masterpiece:1.2), 1girl, (red hair:1.3), blue eyes, [glasses]" \
--negative-prompt "(bad quality, worst quality:1.4)" \
--steps 20 --seed 42
```
### BREAK (condition chunking)
Split the prompt into independent conditioning chunks with `BREAK`:
```bash
vnasset generate \
--prompt "1girl, red hair, standing BREAK blue sky, cherry blossoms" \
--steps 20 --seed 42
```
Use `--raw` to bypass weighting and fall back to plain diffusers encoding.
## Future Improvements
@@ -180,5 +202,4 @@ workflow. compel integration is planned for later.
availability or a ComfyUI installation.
- **Qwen Image Edit support** — `vnasset edit` and `vnasset pipeline` for
batch expression/outfit variant editing.
- **compel prompt weighting** — support `(word:weight)` and `BREAK` syntax for
parity with ComfyUI prompt encoding.