adieyal / dynamicprompts

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

Have internal sampling APIs return SamplingResults #100

Closed akx closed 1 year ago

akx commented 1 year ago

This will allow for additional metadata to be gathered during sampling (e.g. wildcard files used, and other future magic).

codecov-commenter commented 1 year ago

Codecov Report

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

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

Files Coverage Δ
src/dynamicprompts/generators/combinatorial.py 100.00% <100.00%> (ø)
src/dynamicprompts/generators/randomprompt.py 100.00% <100.00%> (ø)
src/dynamicprompts/jinja_extensions.py 98.18% <100.00%> (+1.81%) :arrow_up:
src/dynamicprompts/samplers/base.py 93.18% <100.00%> (+0.15%) :arrow_up:
src/dynamicprompts/samplers/combinatorial.py 97.40% <100.00%> (-0.28%) :arrow_down:
src/dynamicprompts/samplers/command_collection.py 100.00% <100.00%> (ø)
src/dynamicprompts/samplers/cycle.py 94.11% <100.00%> (+0.11%) :arrow_up:
src/dynamicprompts/samplers/random.py 95.55% <100.00%> (+0.10%) :arrow_up:
src/dynamicprompts/samplers/utils.py 100.00% <100.00%> (ø)
src/dynamicprompts/sampling_context.py 97.84% <100.00%> (ø)
... and 12 more

:loudspeaker: Thoughts on this report? Let us know!.

adieyal commented 1 year ago

Looks good - happy for me to publish a new version?

akx commented 1 year ago

This shouldn't change any high-level APIs, so yeah, fine by me :)

Thanks!

adieyal commented 1 year ago

@akx, there is a backwards in compatible change in this PR. When updating the dependency in the extension, I get the following:

  File "./stable-diffusion-webui/extensions/sd-dynamic-prompting/sd_dynamic_prompts/wildcards_tab.py", line 246, in handle_message
    return handle_load_wildcard(event)
  File "./stable-diffusion-webui/extensions/sd-dynamic-prompting/sd_dynamic_prompts/wildcards_tab.py", line 267, in handle_load_wildcard
    values = "\n".join(wf.get_values())
TypeError: sequence item 0: expected str instance, WildcardItem found
> ./stable-diffusion-webui/extensions/sd-dynamic-prompting/sd_dynamic_prompts/wildcards_tab.py(268)handle_load_wildcard()
-> values = "\n".join(wf.get_values())
(Pdb) print(wf.get_values())
[WildcardItem(content='red', weight=99.0), WildcardItem(content='green', weight=1.0)]
(Pdb) print(str(w) for w in wf.get_values())
<generator object <genexpr> at 0x7f14c05f9150>
(Pdb) print(list(str(w) for w in wf.get_values()))
['red', 'green']
akx commented 1 year ago

@adieyal That's #97, actually, not this one. That's expected though – sddp can just always cast to strings for the tab display IMO :)