sd-dynamic-prompts icon indicating copy to clipboard operation
sd-dynamic-prompts copied to clipboard

BUG: Dynamic Prompt generated PNG info cannot be read back via txt2img button

Open tusharbhutt opened this issue 2 years ago • 12 comments

Describe the bug When you read the PNG info from a file and then send it to the TXT2IMG tab via the txt2img button, all the parameters other than the positive prompt goes to the correct spot), go into the negative prompt box. The same occurs when using the Image browser and I suspect anything with the txt2img button. Seeds, steps, CFG, etc are all put into the negative prompt too when they should go into their respective fields.

NOTE: this issue does not occur when using PNG info from vanilla AUTO1111 images

image

To Reproduce Steps to reproduce the behaviour, include the prompt you used if applicable:

  1. Find an image with PNG info
  2. Press txt2img to send to the txt2img tab
  3. Note where the parameters end up

Also mention which checkboxes have been set.

Ignore whitespaces, insert template into PNG (may be this one....)

Are you using a local install or a colab?

Local

If a colab, which one?

Expected behaviour A clear and concise description of what you expected to happen.

The parameters after the negative prompt ends should go into the proper fields (CFG, steps, etc)

Additional context

Here is the generated PNG Info to test:


parameters

epic (Children’s drawing) of (An underground Oasis:1.2), professional (Naive genre:0.5), (Nuclear style:0.5), mythical mood, best, astonishing, impressive, outstanding, stunning, gorgeous, much detail, much wow, global dynamic lighting, cinematic, perfect, detailed textures, masterpiece
Negative prompt: logo, text,watermark, istock, shutterstock, getty, alamy, dreamstime, yayimages,adobe stock,signature,icon,Neg_FaceLift768,NegLowRes-1000 ,neg_Colorizer768-warm,NegMutation-2000,no_unrealistic768
Steps: 30, Sampler: DPM++ SDE Karras, CFG scale: 7, Seed: 2050696836, Size: 768x768, Model hash: 4bdfc29c, Model: StabilityAI_Stable21-768-ema-pruned, Denoising strength: 0.62, Eta: 0.89, Hires resize: 1536x1024, Hires steps: 30, Hires upscaler: Latent (bicubic antialiased)
Template:epic (__mediumnew__) of (__hotpot__:1.2), professional (__genrenew__ genre:0.5), (__aestheticsnew__ style:0.5), __moodsnew__ mood, best, astonishing, impressive, outstanding, stunning, gorgeous, much detail, much wow, global dynamic lighting, cinematic, perfect, detailed textures, masterpiece
Negative Template:logo, text,watermark, istock, shutterstock, getty, alamy, dreamstime, yayimages,adobe stock,signature,icon,Neg_FaceLift768,NegLowRes-1000 ,neg_Colorizer768-warm,NegMutation-2000,no_unrealistic768, aesthetic_score: 6.9

aesthetic_score

6.9

tusharbhutt avatar Jan 11 '23 05:01 tusharbhutt

I added some thoughts and suggestions about this feature in the original discussion thread: https://github.com/adieyal/sd-dynamic-prompts/discussions/149#discussioncomment-4673595

masslevel avatar Jan 13 '23 02:01 masslevel

Oh OK! Good to know, I'll close this one.

tusharbhutt avatar Jan 13 '23 21:01 tusharbhutt

@tusharbhutt , @masslevel

I've pushed a fix to a new branch. Could you please test before I merge into the main branch?

In extensions/sd-dynamic-prompt run these commands:

git pull -a
git checkout bug/copypaste-parameters

You can get back to main with: git checkout main

adieyal avatar Jan 21 '23 18:01 adieyal

@tusharbhutt , @masslevel

I've pushed a fix to a new branch. Could you please test before I merge into the main branch?

Giving it a try now... did not work:

image

tusharbhutt avatar Jan 22 '23 18:01 tusharbhutt

👍 , still happens to me too. Something about this extension's additions to the metadata makes A1111 unable to parse any of it back into the UI...

akx avatar Jan 26 '23 15:01 akx

I haven't had a chance to look into why the patch didn't fix it since it was working when I pushed. The way metadata is written to the png is using the on_before_image_saved callback

Auto's parsing is a little fiddly. The last line is assumed to the settings (cfg, steps, etc). Then it reads the remaining metadata line by line until it gets to negative prompt. And splits it into positive and negative prompts. Since DP appends the template to that metadata, the parameters assumption doesn't hold anymore.

In order to fix it, remove_template_from_infotext is called by the on_infotext_pasted callback.

Before the metadata is parsed, remove_template_from_infotext removes the template. I'll need to look into why this hasn't been working.

adieyal avatar Jan 26 '23 17:01 adieyal

Out of curiosity, which script reads/writes the metadata?

tusharbhutt avatar Jan 28 '23 03:01 tusharbhutt

You mean in auto1111? modules/generation_parameters_copypaste.py

adieyal avatar Jan 28 '23 12:01 adieyal

Yes, thanks. I'm trying to get the PNG data imported into Lightroom via EXIFTool and with the arbitrary number of parameters passed plus colons being used in the prompts and as delimiters, it's a tough slog :)

tusharbhutt avatar Jan 28 '23 18:01 tusharbhutt

Just had this issue today, turning on the "template in PNG info" setting breaks PNG info's send to txt2img function.

Adil3tr avatar Feb 02 '23 02:02 Adil3tr

Are there any news on this issue? I just found out, that this is why some data is not being sent from the image browser extension to a1111.

https://github.com/AlUlkesh/stable-diffusion-webui-images-browser/issues/153#issuecomment-1742108654

AlUlkesh avatar Oct 01 '23 15:10 AlUlkesh

This PR should fix that.

AlUlkesh avatar Oct 02 '23 14:10 AlUlkesh