AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
141.82k stars 26.79k forks source link

[Bug]: Prompt Weighting with Brackets doesn't match non-Bracket behavior. #13794

Open Meerkov opened 12 months ago

Meerkov commented 12 months ago

Is there an existing issue for this?

What happened?

The following produce distinct images [cat:0] {cat:0} -> Edit: this is actually 5 tokens (cat:0) cat:0

These all are identified as a single token. The weight is the same in all cases. Only the last one produces a result which is recognizable as containing no cat, though the latent noise mid-generation shows a cat temporarily.

image image image image

Steps to reproduce the problem

image cat:-1

image (cat:-1)

image [cat:-1]

The same issue appears when using -1 weights. Only by using no brackets can you get an image which properly has no cat.

What should have happened?

It's clear that there is a bug in the system for weighting brackets, when compared to the same prompt with no brackets.

Sysinfo

.

What browsers do you use to access the UI ?

No response

Console logs

.

Additional information

No response

Meerkov commented 12 months ago

I used the following tool to help debug https://www.lark-parser.org/ide/ According the prompt Lark script, this seems to be caused in part by the following: [cat:-1] -> this produces a schedule which begins using cat at step -1. No clue why this is different than 0. [cat:0] -> this produces a schedule which begins using cat at step 0. The weight is presumably 1.0. {cat:0} -> this produces plain text {cat:0} with no special meaning. (cat:0) -> this produces an emphasis with cat, but the weight is some non-zero amount due to a bug (reported elsewhere). cat:0 -> this actually negates the cat keyword correctly.

Woisek commented 12 months ago

You want to produce an image without a cat ... and write cat into the prompt ... ? 🤔

Meerkov commented 12 months ago

You want to produce an image @Woisek please don't comment unless you have something helpful to say. The bug has nothing to do with me "wanting to produce an image". It's about the bracket system being a mess and clearly not working as expected.

In short: prompt : X -> correctly weights the prompt with X weight (prompt:X) -> doesn't