Skip to content
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

feat: simplify and enhance prompt weight splitting #258

Merged

Conversation

nderscore
Copy link
Contributor

@nderscore nderscore commented Aug 31, 2022

  • Simplify split_weighted_subprompts method by replacing most of the logic with single a regular expression
  • The original syntax is still fully supported, but has been expanded to handle all of the following variations of the syntax:
    • foo:2 integers
    • foo:-1.23 decimals and negative numbers
    • foo: no weight (defaults to 1)
    • foo::123 midjourney-style double-colon syntax
    • foo:2bar:1 foo:bar missing space characters between subprompts? no problem
    • foo:2 bar:1 spaces are fine too though
    • foo:    bar foo:1.2    bar:3 multiple spaces as well
    • foo:2 bar and the last subprompt doesn't need a colon
    • foo and a plain prompt works still too
  • (Edit:) Added support for escaping colon characters with a backslash
    • When escaped, actual colon characters are inserted into prompt tokens
    • foo\:bar -> foo:bar unsplit
  • Add a guard against normalization code breaking when prompt weights add up to 0
  • Move weight normalization code into the split_weighted_subprompts method as an argument

@nderscore nderscore force-pushed the feat-simplify-prompt-weight-splitting branch from d469eb7 to cf7abd6 Compare August 31, 2022 16:35
@lstein lstein self-requested a review August 31, 2022 16:35
Copy link
Collaborator

@lstein lstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this out with a variety of weighting formats and it seems to be performing as advertised. I also compared images from this version to the previous weighted prompt implementation, and they were identical. Thank you!

@lstein lstein merged commit c52ba1b into invoke-ai:main Aug 31, 2022
austinbrown34 pushed a commit to cognidesign/InvokeAI that referenced this pull request Dec 30, 2022
* feat: simplify and enhance prompt weight splitting

* fix: don't shadow the prompt variable

* feat: enable backslash-escaped colons in prompts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants