adieyal / sd-dynamic-prompts

A custom script for AUTOMATIC1111/stable-diffusion-webui to implement a tiny template language for random prompt generation
MIT License
2.03k stars 261 forks source link

[BUG] Immediate evaluation of variables not behaving as expected. #421

Open rjgoif opened 1 year ago

rjgoif commented 1 year ago

The instructions here are a bit unclear, but it seems like you should be able to do exhaustive combinatorial variable selection. It currently does not work.

Based on this prompt:

${season=!{summer|autumn|winter|spring}}
${season} scene, man in ${season} outfit.

and checking the Combinatorial generation box, expect:

Expected result

4 prompts

summer scene, man in summer outfit.
autumn scene, man in autumn outfit.
winter scene, man in winter outfit.
spring scene, man in spring outfit.

Instead, it only makes one prompt:

Actual result

1 prompt

summer scene, man in summer outfit.

Correct counterexample

I assume that the expected behavior is the exhaustively iterate through the variable. This occurs as expected if "Immediate evaluation" isn't selected:

${season={summer|autumn|winter|spring}}
${season} scene, man in ${season} outfit.

yields

summer scene, man in summer outfit.
summer scene, man in autumn outfit.
summer scene, man in winter outfit.
summer scene, man in spring outfit.
autumn scene, man in summer outfit.
autumn scene, man in autumn outfit.
autumn scene, man in winter outfit.
autumn scene, man in spring outfit.
winter scene, man in summer outfit.
winter scene, man in autumn outfit.
winter scene, man in winter outfit.
winter scene, man in spring outfit.
spring scene, man in summer outfit.
spring scene, man in autumn outfit.
spring scene, man in winter outfit.
spring scene, man in spring outfit.
patrickchamp commented 1 year ago

I had the same issue and may have just found a fix. I had the Unprompted extension enabled. When disabled, it fixes this issue.

layluke commented 1 year ago

I was able to fix this by moving the folder for the extension to a folder outside the directory, and then re-installing it, then moving my wildcards back:

  1. stop sd
  2. move folder to desktop (or any other folder outside of the extension folder)
  3. start sd
  4. re-install dynamic-prompts
  5. stop sd
  6. Moved wildcard folder from backup into new installation location
  7. start sd

This worked for me. Don't know if something got corrupted from usage, or from a git pull.

rjgoif commented 1 year ago

I was able to fix this by moving the folder for the extension to a folder outside the directory, and then re-installing it, then moving my wildcards back:

1. stop sd

2. move folder to desktop (or any other folder outside of the extension folder)

3. start sd

4. re-install dynamic-prompts

5. stop sd

6. Moved wildcard folder from backup into new installation location

7. start sd

This worked for me. Don't know if something got corrupted from usage, or from a git pull.

Tried this, no effect. Sill only generates a single prompt even with combinatorial checked.

rjgoif commented 1 year ago

I had the same issue and may have just found a fix. I had the Unprompted extension enabled. When disabled, it fixes this issue.

Nope, I don't have that extension installed. Disabling every extension and restarting SD didn't work - even when the only extension is a freshly installed Dynamic Prompts, it fails.

layluke commented 1 year ago

I was able to fix this by moving the folder for the extension to a folder outside the directory, and then re-installing it, then moving my wildcards back:

1. stop sd

2. move folder to desktop (or any other folder outside of the extension folder)

3. start sd

4. re-install dynamic-prompts

5. stop sd

6. Moved wildcard folder from backup into new installation location

7. start sd

This worked for me. Don't know if something got corrupted from usage, or from a git pull.

Tried this, no effect. Sill only generates a single prompt even with combinatorial checked.

yeah, just had this issue happen once again, and these steps did not work this time.

rodrgomes commented 1 year ago

Can confirm that I have the same bug.. is there some workaround to it?

MrUrzza commented 1 year ago

Can confirm this issue still occurs

rjgoif commented 9 months ago

Most recent update (applied 18-Dec-2023) still has this bug.

I found a workaround that works without using variables by utilizing the poorly documented cyclical operator "@" in combinatorial mode. Example producing the expected 4 prompts:

{@summer|autumn|winter|spring} scene, man in {summer|autumn|winter|spring} outfit.

From this, I extended it to simple variable definitions:

${season={summer|autumn|winter|spring}}
{@${season}} scene, man in ${season} outfit

Once you start adding other variables or even a third callout to the same variable, things start to break down and the ordered matching no longer applies correctly.