adieyal / sd-dynamic-prompts

A custom script for AUTOMATIC1111/stable-diffusion-webui to implement a tiny template language for random prompt generation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Templates written to image metadata have \n instead of newline character

morecatplease opened this issue · comments

I love this extension and want to thank the creators for maintaining it. I just updated to version 284d3ef, and how the prompt template is written to the image metadata has changed. Now the template has \n inserted where newlines should be.

Just making up an example, if the prompt is:

Fast cars {
<lora:somelora:0.8>|
<lora:loratwo:0.2>|
<lora:lorathree:0.3
}

What gets written to the template is

Template: "Fast cars {\n<lora:somelora:0.8>|\n<lora:loratwo:0.2>|\n<lora:lorathree:0.3\n}"

The template saving feature is amazing because you could, in Automatic1111, just drop an old image into the PNG Info tab, copy the whole template with wildcards out of the metadata, and paste it into a new prompt. Now, if you have multiple lines in your prompt, you have to paste it into a text editor and replace all the "\n" with a newline.
Thank you!

This is expected after #691 (cc @w-e-w); in one way, it's an improvement over the previous code (where a computer couldn't easily figure out where a multi-line template would end). I don't honestly know enough about the metadata system to know if there's a way for the PNG Info tab to un-mangle quoted metadata so it'd be easier copy-pasted.

the problem with is the previous old syntax was causing the infotext to be invalid to others when sd-dynamic-prompts is not installed
and people make a report about it and thinking that it is something that webui did that borke infotext but the truth is actually opposite

the infotext is designed to be read by machines while remaining readable to a certain level of degree
one of the restrictions on how auto coded the infotext syntax make it so that you cannot have literal new line in it
normally when something is in the infotext it will be automatically read back and by the UI so and humans won't have to manually copy and paste and so not a problem

but since sd-dynamic-prompts does not use the template intotext it itself this causes issue of the infotext being "not friendly"

potential ways of solving the issue

  1. add a button of some kind that will automatically do the copy parse and paste for you

  2. hijack run_pnginfo(image) and make it generate infotext html with template parsed for the user and displayed in newline
    not as opposed to be back in the hijack you could use javascript to achieve the same effect in the front end


got a similer report days ago
AUTOMATIC1111/stable-diffusion-webui#14545