adieyal / dynamicprompts

Templating language for generating prompts for text to image generators such as Stable Diffusion
MIT License
124 stars 20 forks source link

(feat) Add Variable Support in Wildcard Paths #110

Closed mwootendev closed 11 months ago

mwootendev commented 12 months ago

Adds support for the issue described in #614 of sd-dynamic-prompts. The patch adds support for allowing variable refences within wildcard paths (e.g. __cars/${car}/types__). During the parsing phase, the variables will be retained in the path. During sampling, before resolving the wildcard, the variable is first resolved and replaced in the wildcard.

The update should allow support for variable replacement, including providing default values using the normal :default syntax. Some examples:

The test cases were updated to test a variety of scenarios.

codecov-commenter commented 12 months ago

Codecov Report

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

Comparison is base (510d1e9) 97.47% compared to head (99778b7) 97.43%.

Files Patch % Lines
src/dynamicprompts/samplers/utils.py 88.57% 4 Missing :warning:

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

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #110 +/- ## ========================================== - Coverage 97.47% 97.43% -0.05% ========================================== Files 77 77 Lines 3249 3352 +103 ========================================== + Hits 3167 3266 +99 - Misses 82 86 +4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

mwootendev commented 12 months ago

@akx Thank you for the in-depth feedback. I'll be honest, this is my first time trying work with Python, so I'm unfamiliar with many of the idioms. I've mostly done Java, JavaScript, and TypeScript development, so I appreciate the Python guidance. I hope this last update resolved all of your concerns.

akx commented 12 months ago

@mwootendev Tests seem to be now failing 😩

mwootendev commented 12 months ago

@mwootendev Tests seem to be now failing 😩

This should be resolved in the latest push. In the case where the variable was None it failed that check.