AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
140.72k stars 26.62k forks source link

[Bug]: 1.8.0 Prompt truncated when it contains escape sequence characters #15093

Open Dmytri-Kirov opened 7 months ago

Dmytri-Kirov commented 7 months ago

Checklist

What happened?

Updated to 1.8.0 and used prior prompts from SD images. The results windows shows that upon reaching "'" the remainder of prompt is ignored after '&' character, even though the prompt window contains the entire prompt. Occurs at first instance of sequence.

Steps to reproduce the problem

Prompt window contains: (Of course! Imagine a charming black-and-white poster from 1956 featuring a polar bear dressed in a suit and glasses, seated at a desk covered in paperwork and various writing instruments. The Arctic landscape serves as the backdrop, with icebergs and snowdrifts providing a serene yet humorous contrast to the bear's bureaucratic duties. A banner above reads "Tax Time Hits Even the Frozen Frontier - File Accurately, Bear-ly!" capturing both puns and the sense of responsibility associated with tax season. In the corner, a tiny red inkwell symbol represents the Internal Revenue Service (IRS) of that era, further adding to the whimsical tone of this delightful poster.:1)

Result window contains: (Of course! Imagine a charming black-and-white poster from 1956 featuring a polar bear dressed in a suit and glasses, seated at a desk covered in paperwork and various writing instruments. The Arctic landscape serves as the backdrop, with icebergs and snowdrifts providing a serene yet humorous contrast to the bear&

As example of truncation. The escape sequence in prompt is part of Oobabooga being used as input, but effect the same if typed with "&#27" The effect in this example is minor (but safe).

What should have happened?

Results window should show entire prompt as before.

What browsers do you use to access the UI ?

Microsoft Edge

Sysinfo

System does not indicate any error condition occurred.

Console logs

no console start up issue reported.

Additional information

No response

Dmytri-Kirov commented 7 months ago

Okay, this bug report also shows the processing of the escape sequence while the prompt was truncated. Key is the classic escape character 27 cause prompt processing to truncate.

missionfloyd commented 7 months ago

Disable prompt comments. Settings > Stable Diffusion > Enable comments.

Dmytri-Kirov commented 7 months ago

Thank you. The suggestion to disable prompt comments did not work.

The core issue is that Automatic1111 1.8.0 is processing the prompt and when it comes to the ampersand-hash-27-semicolon sequence, it stops processing the prompt and truncates it. Because I use automated prompt generators, the replacement of apostrophe, single quote and double quotes are replaced by escape sequences to prevent the data from being treated as a control information. A1111 is doing just that, it sees the sequence and truncates it because tries to process it as control info or rejects automatically. Somewhere, possibly the prompt processing/parser is tripping on the situation. Is their an option on how the prompt window parses the escape sequence? I don't know, but the issue seems to reside in that area.

Dmytri-Kirov commented 7 months ago

A simplified test, prompt = "polar bear on an iceberg that &# orange" result window reflects = "polar bear on an iceberg that &" prompt = "polar bear on an iceberg that # orange" result window reflects = "polar bear on an iceberg that"

It is the "#" that triggers the truncation, plain and simple.

missionfloyd commented 7 months ago

Here's what I get.

Comments on: comments

polar bear on an iceberg that

Steps: 20, Sampler: Euler a, CFG scale: 4.0, Seed: 3470442773, Size: 512x512, Model hash: ec41bd2a82, Model: photon_v1, VAE hash: 235745af8d, VAE: vae-ft-mse-840000-ema-pruned.safetensors, Version: v1.8.0

Comments off: nocomments

polar bear on an iceberg that # orange
Steps: 20, Sampler: Euler a, CFG scale: 4.0, Seed: 3470442773, Size: 512x512, Model hash: ec41bd2a82, Model: photon_v1, VAE hash: 235745af8d, VAE: vae-ft-mse-840000-ema-pruned.safetensors, Version: v1.8.0
Dmytri-Kirov commented 7 months ago

read &-#-27-; as existing without the dashes in the prompt text.

The above images are the same because the # truncates, if the # is removed, there is a difference since "orange" goes thru. The prompts I use are generated by other applications which replace single quotes/apostrophes with &-#-27-; and thus prompt truncated. version 1.7.0 did not have a problem with these prompts but when I copy those same prompts in version 1.8.0 the results show the prompt processed as truncated at the point of the #. It is a quirk and requires me to change the upstream prompt generation.

It is different when I updated to v1.8.0, maybe it is how # is supposed to work in a prompt now.
I now know I can't copy the "PNG Info" tab data over via "Send to txt2img" for an existing image and get the same result if a # is in the prompt because of a &-#-27-; replaced a single quote mark/apostrophe.

missionfloyd commented 7 months ago

They're not the same; disabling comments worked for me. Did you click apply after unchecking it?