AUTOMATIC1111 / stable-diffusion-webui

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

[Feature Request]: Allow order of operations on prompt parser #16507

Open fcolecumberri opened 1 month ago

fcolecumberri commented 1 month ago

Is there an existing issue for this?

What would your feature do ?

Imagine the next prompt:

a cat AND a dog BREAK on a beach

Here this prompt can be parsed on 2 different ways:

1

a cat ━━━┓
         ┣━━┓
a dog ━━━┛  ┃
on a beach ━┻━━ OUTPUT

2

a cat ━━━━━━━━━━━┳━━ Output
a dog ━━━━━━━━┓  ┃
              ┣━━┛
on a beach ━━━┛

Both ways ends up with a different result. (drawing this ended up being more difficult than it looks) My proposal is to do something similar to how math works, by a parenthesis-equivalent keywords, something like BEGIN/END so by doing that, now:

BEGIN a cat AND a dog END BREAK on a beach

and

a cat AND BEGIN a dog BREAK on a beach END

This is also relevant since other extensions create their own keywords and usually collide since there is no way to express order of operations. Having a native to the tool way of doing it might force the extension developers to respect them as well.

Proposed workflow

No change on workflow, just a couple of keywords.

Additional information

No response

wkpark commented 1 month ago

[from:to:when] prompt syntax could be used for it.

for example [a cat:a dog:0.5] on a beach

see also https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#prompt-editing

fcolecumberri commented 1 month ago

[from:to:when] prompt syntax could be used for it.

for example [a cat:a dog:0.5] on a beach

see also https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#prompt-editing

That could be a good hack for some cases, but that's not the same.