thundaga / SD-webui-txt2img-script

Stable diffusion webui script to batch process images within the txt2img section
41 stars 5 forks source link

Prompts added by using styles dropdown not picked up by script #14

Closed spryroX closed 1 year ago

spryroX commented 1 year ago

I've noticed sometimes that the generations by the script did not match the original image, even with all "Assign from input image" options enabled. It turns out that whenever you add prompts via the "Styles" dropdown from standard Automatic1111 they are not being picked up correctly by the script.

Oddly enough, when you drag the original images into the "Prompt" section it does show the correct prompt. Not sure exactly what the the "Prompt" bar from Automatic1111 is doing different from the class that the script uses to extract the prompts.

To reproduce:

  1. Create image using regular prompt
  2. Generate image (baseline)
  3. Add something to prompt by using style lookup in A1111 (with or without using the paste button)
  4. Generate image
  5. Run both generated images to the script and most likely you will output the same image twice, even though the originals are different.

I haven't managed to reproduce this with 100% accuracy. Sometimes it seems to inexplicably work. Copying of the prompt with the included part from styles to notepad and back into the prompt bar still doesn't fix the issue, so I have no clue what exactly is going on in the background that is causing this.

OPCOXE commented 1 year ago

Hi,

I'll check later, did you check the infotext ? It doesn't sound like a script issue for me, I'm not sure but I think that the webui does't put the style in the prompt but into an extra parameter or something.

EDIT: Okey there is an issue I'll check what's happening

OPCOXE commented 1 year ago

Ok I found the issue, like I said the Style prompt isn't stored and only the Style name is : "Styles array": ["test"] I'm not sure we can fix it as even the webui doesn't apply directly the Style and just load it in the Style Dropdown menu.

In fact, I just added a comma at the end of the prompt (after apply the style) and everything was stored in the prompt and the script worked properly

spryroX commented 1 year ago

Ok I found the issue, like I said the Style prompt isn't stored and only the Style name is : "Styles array": ["test"] I'm not sure we can fix it as even the webui doesn't apply directly the Style and just load it in the Style Dropdown menu.

In fact, I just added a comma at the end of the prompt (after apply the style) and everything was stored in the prompt and the script worked properly

The weird thing is that when you drag the generated image into the prompt box it does take include the style correctly, so it must be saved somewhere right?

OPCOXE commented 1 year ago

Yeah in the EXIF but the script uses the inbuild function of the webui called parse_generation_parameters it works the same as when you click the Send to txt2img button on the PNG Info tab. The function return the script name instead of the full prompt, I can't tell how it works

OPCOXE commented 1 year ago

I just checked and the parse_generation_parameters take the EXIF as value and return an object with the values. It's the function itself that remove the style from the prompt and put it as an independent value inside the object.

It means that to fix the issue, that only require to either not use style or just do an edition of the prompt afterward, we need to create an entire parsing function. I, personally, won't do that it's not cost efficient (too small impact for a too big change)