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.06k stars 267 forks source link

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

Open tusharbhutt opened 1 year ago

tusharbhutt commented 1 year ago

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
masslevel commented 1 year ago

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

tusharbhutt commented 1 year ago

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

adieyal commented 1 year ago

@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

tusharbhutt commented 1 year ago

@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

akx commented 1 year ago

👍 , 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...

adieyal commented 1 year ago

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.

tusharbhutt commented 1 year ago

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

adieyal commented 1 year ago

You mean in auto1111? modules/generation_parameters_copypaste.py

tusharbhutt commented 1 year ago

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 :)

Adil3tr commented 1 year ago

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

AlUlkesh commented 1 year ago

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 commented 1 year ago

This PR should fix that.