feat: add \00\00\00 as separator for prompts and infotext

This commit is contained in:
bluelovers 2024-05-05 16:12:15 +08:00
parent ddb28b33a3
commit cba1238cd1
3 changed files with 9 additions and 7 deletions

View File

@ -250,13 +250,14 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
done_with_prompt = False done_with_prompt = False
*lines, lastline = x.strip().split("\n") separator = '\00\00\00\n' if '\00\00\00\n' in x.strip() else '\n'
*lines, lastline = x.strip().split(separator)
if len(re_param.findall(lastline)) < 3: if len(re_param.findall(lastline)) < 3:
lines.append(lastline) lines.append(lastline)
lastline = '' lastline = ''
for line in lines: for line in lines:
line = line.strip() line = line.strip().replace('\00', '')
if line.startswith("Negative prompt:"): if line.startswith("Negative prompt:"):
done_with_prompt = True done_with_prompt = True
line = line[16:].strip() line = line[16:].strip()
@ -296,8 +297,8 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
if (shared.opts.infotext_styles == "Apply if any" and found_styles) or shared.opts.infotext_styles == "Apply": if (shared.opts.infotext_styles == "Apply if any" and found_styles) or shared.opts.infotext_styles == "Apply":
res['Styles array'] = found_styles res['Styles array'] = found_styles
res["Prompt"] = prompt res["Prompt"] = prompt.replace('\00', '')
res["Negative prompt"] = negative_prompt res["Negative prompt"] = negative_prompt.replace('\00', '')
# Missing CLIP skip means it was set to 1 (the default) # Missing CLIP skip means it was set to 1 (the default)
if "Clip skip" not in res: if "Clip skip" not in res:

View File

@ -813,9 +813,9 @@ def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iter
generation_params_text = ", ".join([k if k == v else f'{k}: {infotext_utils.quote(v)}' for k, v in generation_params.items() if v is not None]) generation_params_text = ", ".join([k if k == v else f'{k}: {infotext_utils.quote(v)}' for k, v in generation_params.items() if v is not None])
negative_prompt_text = f"\nNegative prompt: {negative_prompt}" if negative_prompt else "" negative_prompt_text = f"\00\00\00\nNegative prompt: {negative_prompt}" if negative_prompt else ""
return f"{prompt_text}{negative_prompt_text}\n{generation_params_text}".strip() return f"{prompt_text}{negative_prompt_text}\00\00\00\n{generation_params_text}".strip()
def process_images(p: StableDiffusionProcessing) -> Processed: def process_images(p: StableDiffusionProcessing) -> Processed:

View File

@ -29,7 +29,8 @@ def update_generation_info(generation_info, html_info, img_index):
def plaintext_to_html(text, classname=None): def plaintext_to_html(text, classname=None):
content = "<br>\n".join(html.escape(x) for x in text.split('\n')) separator = '\00\00\00\n' if '\00\00\00\n' in text else '\n'
content = "<br>\n".join(html.escape(x) for x in text.split(separator))
return f"<p class='{classname}'>{content}</p>" if classname else f"<p>{content}</p>" return f"<p class='{classname}'>{content}</p>" if classname else f"<p>{content}</p>"