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

Add wrap command #102

Merged
merged 1 commit into from
Nov 20, 2023
Merged

Add wrap command #102

merged 1 commit into from
Nov 20, 2023

Conversation

akx
Copy link
Collaborator

@akx akx commented Nov 6, 2023

This PR adds a new wrap command.

The test says it all:

  • Given a prompt "%{__wrappers__$${fox|cow}}"
  • and the wildcard file wrappers with
    • Art Deco, ..., sleek, geometric forms, art deco style
    • Pop Art, ...., vivid colors, flat color, 2D, strong lines, Pop Art
  • we generate
    • Art Deco, cow, sleek, geometric forms, art deco style
    • Art Deco, fox, sleek, geometric forms, art deco style
    • Pop Art, cow, vivid colors, flat color, 2D, strong lines, Pop Art
    • Pop Art, fox, vivid colors, flat color, 2D, strong lines, Pop Art

IOW, a marker string (3+ regular dots, or 1+ Unicode ellipsis character) within the wrapper component of the wrap command will be replaced with the inner command's sampling result.

This also works for things other than wildcards (despite the branch name):

%{{happy|sad} ... in a {car|plane}$${programmer|dog}}

...

@akx
Copy link
Collaborator Author

akx commented Nov 6, 2023

WDYT @adieyal?

@akx akx added the enhancement New feature or request label Nov 7, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 7, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files Coverage Δ
src/dynamicprompts/commands/__init__.py 100.00% <100.00%> (ø)
src/dynamicprompts/commands/wrap_command.py 100.00% <100.00%> (ø)
src/dynamicprompts/parser/config.py 100.00% <100.00%> (ø)
src/dynamicprompts/parser/parse.py 98.37% <100.00%> (+0.07%) ⬆️
src/dynamicprompts/samplers/combinatorial.py 97.56% <100.00%> (+0.15%) ⬆️
src/dynamicprompts/samplers/random.py 96.00% <100.00%> (+0.44%) ⬆️
src/dynamicprompts/sampling_result.py 100.00% <100.00%> (ø)
tests/test_wrapping.py 100.00% <100.00%> (ø)
tests/utils.py 100.00% <100.00%> (ø)
tests/wildcard/test_wildcardmanager.py 100.00% <ø> (ø)
... and 1 more

📢 Thoughts on this report? Let us know!

@akx akx changed the title Add wrap command (beta/proof of concept/WIP) Add wrap command Nov 7, 2023
@akx akx requested a review from adieyal November 7, 2023 08:44
@akx akx marked this pull request as ready for review November 7, 2023 08:45
@akx akx marked this pull request as draft November 7, 2023 08:59
@akx akx marked this pull request as ready for review November 7, 2023 09:19
@adieyal
Copy link
Owner

adieyal commented Nov 8, 2023

WDYT @adieyal?

I like the general idea of infill, although it feels a little complicated to use. Is the % necessary? Can we not assume that ellipses in the wrapper mean infill? I don't think that would break any existing workflows since the wrappers was only used as a separator before.

Do you have any concrete use cases that you've used it for?

@akx
Copy link
Collaborator Author

akx commented Nov 9, 2023

I like the general idea of infill, although it feels a little complicated to use. Is the % necessary? Can we not assume that ellipses in the wrapper mean infill? I don't think that would break any existing workflows since the wrappers was only used as a separator before.

I agree it's a bit unwieldy. Without some sort of syntax like this, how would the wrapper know what to wrap? The examples from the tests are

  • %{__wrappers__$${fox|cow}} (using templates from wildcards to wrap two possible variations)
  • %{happy ... on a meadow$${fox|cow}} (using a verbatim string to wrap two possible variations)
  • %{ {cool|hot} ...$${fox|cow}} (using a variation command in the wrapper part too)

Do you have any concrete use cases that you've used it for?

I've ported the Fooocus style templates from https://github.com/lllyasviel/Fooocus/tree/main/sdxl_styles to wrapping wildcards, and have had fun with that; please enjoy this stably diffused melon:

00059-20231107202053-885656039

@akx
Copy link
Collaborator Author

akx commented Nov 20, 2023

@adieyal WDYT, should we merge this? I don't think the %{a...c$$b} syntax should be breaking any current workflows, even if it is a bit unwieldy (if someone comes up with a lighter-weight syntax later, we could ship that too)?

@adieyal
Copy link
Owner

adieyal commented Nov 20, 2023 via email

@akx akx merged commit 510d1e9 into adieyal:main Nov 20, 2023
7 checks passed
@akx akx deleted the wrapping-wildcard branch March 21, 2024 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants