-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display improvements to PNG Info tab #16415
base: dev
Are you sure you want to change the base?
Display improvements to PNG Info tab #16415
Conversation
Text on PNG Info tab is parsed and colorized in a way that makes it easier to read. Parameter values can be copied by clicking on them. - High performance regex used for parsing - Normal values are displayed in blue, but string content is displayed in orange to improve readability (i.e. adetailer prompts) - Clicking to copy uses a pointer cursor and a green color animation to show something is happening - Color choices configured differently for dark mode in order to optimize readability - Copying strings with \n automatically converts to newlines during copy operation - Settings that don't follow normal conventions are not parsed, but displayed in the old style (i.e. dynamic prompt templates) - If there are parsing issues (or exceptions), defaults to the old display mode
Lint run against python and javascript
@w-e-w , thank you for taking the time to review my PR. I fixed the problem with no negative prompt. I like the idea of adding a way to copy text, but want to make sure I understand the problem you are describing. I copied the entire text manually and I think the newlines make the info text more readable, and so are beneficial. What do you mean by "it can also cause certain syntax to break"? Thanks! |
- Handled no negative prompt scenario - Include new lines in positive/negative prompts - Added links to the top to copy png info sections (all/positive/negative/settings)
readable does not mean that it's "the same" if someone has an extension that adds extra scripting functionality to prompts input, then for there syntex newline could have special meanings, so adding a extra newline could potentially break ther syntax or change the output there are other use cases that are very sensitive to minor changes |
@w-e-w , I followed your suggestion and added some links to copy text. The "All" button copies text that should be identical to the previous manual copy. Please let me know if this works? Thanks again! |
found a rather hilarious issue 2024-08-25.07_11_47_017.chrome.mp4once the copy button is clicked, it flashes every time you switch to the tab |
@w-e-w thank you, that's a good catch. I'll see if I can fix it. |
@w-e-w fixed it! Thanks again. Really appreciate that you are finding these issues. |
All to Copy Positive to Prompt
@w-e-w , renamed some of the quick links to make it more obvious what is going on. Finished with all changes, now. |
3dc095c
to
9fb7b07
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found a bug
it seems to be removeing / converting double space to single space
seems to be working correctly now while personally like the changes in general but as this maybe controversial so like more feedback before merging one thing I don't like is the stable-diffusion-webui/style.css Lines 1712 to 1716 in 56dc761
|
@w-e-w , thank you for following up. Yes, I understand that the appeal of visual and GUI changes can be subjective and people can have strong opinions about it. I tried to make the text formatting as nice as possible for light and dark modes. I wouldn't expect them to appeal with everyone, but I think even if someone doesn't like all my aesthetic choices, hopefully they feel that it is better than the wall of text we have now. I have been using the changes for about 2 months now with no issues for my prompts. Thanks again. |
modules/png_parser.py
Outdated
def init_re(cls): | ||
if cls.re_top_level is None: | ||
cls.re_top_level = re.compile(r'^(?P<positive>(?:.|\n)*)\nNegative prompt: (?P<negative>(?:.|\n)*)\n(?=Steps: )(?P<parameters>(?:.|\n)*)$') | ||
cls.re_top_level2 = re.compile(r'^(?P<positive>(?:.|\n)*)\nSteps: (?P<parameters>(?:.|\n)*)$') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I broke the parser
let me see if I can fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- when no
Negative prompt
, Stpes is not in the parameters group and so is not displayed and it's not copied when using copy buttons - the regex pattern is using a dangerous assumption that
Steps
must exist and be is the first listed parameter
modules/extras.py
Outdated
def pnginfo_format_quicklink(name): | ||
return f"<span class='geninfo-quick-link' onclick='uiCopyPngInfo(this, \"{name}\")'>[{html.escape(name)}]</span>" | ||
|
||
|
||
def run_pnginfo(image): | ||
if image is None: | ||
return '', '', '' | ||
|
||
geninfo, items = images.read_info_from_image(image) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@w-e-w Thank you for taking the time to go over this. I will take the time to look over the changes and test. It will take a few days. Thank you again!
extract spitting of infotext converting parsing parameters of as fractions so they can be reused elsewhere split_infotext(str) parameters_to_dict(str) parse_parameters(dict) fix edge case issue with negative prompt parsing
allowing user choose between new and old styles of HTML for PNG info page
@MarcusNyne I fix the issues that I mentioned and added an an option for one to switch back to the old stye, can you have a test |
Description
PNG Info tab text display currently looks like a big block of text, which makes it hard to find specific settings, and is a pain when you are trying to copy a setting. This improvement parses PNG Info settings and displays them in a format that makes it easier to read, and also allows a setting to be copied to the clipboard with a simple click.
Features
Code changes
** Non-standard settings identified by a newline outside of quotes, using dynamic prompts as a reference
** Utilized existing formatting methods when possible
** Introduced for formatting, copy to clipboard, and copy animations
** Preserved existing formatting when there is a parsing error
** No changes to plain text format returned by method
** Uses existing CSS variables whenever possible
** Support for dark mode
** Uses @Keyframes animation
** Copies element text to clipboard
** Starts copy animation
Passed python and javascript linting. Passed test process.
Checklist: