adieyal / sd-dynamic-prompts

A custom script for AUTOMATIC1111/stable-diffusion-webui to implement a tiny template language for random prompt generation
MIT License
2.05k stars 266 forks source link

[Feature Request/Inquiry] Implementing Weighting for individual terms in a wildcard list through duplicate entries #657

Closed ezora5t10leib closed 1 year ago

ezora5t10leib commented 1 year ago

When trying to implement weights using Dynamic Prompts with A1111, is it possible to implement weighting for individual items in the list to create statistically accurate outputs? The goal is to make less absurd prompts while still being dynamic by controlling the level of randomness beyond what simply adding weight to the entire list will do. If not, I would like to request this feature.

I tried doing this by having duplicate entries in the wildcard text file itself, and it definitely doesn't seem to work. For example:

Brown Hair Brown Hair Brown Hair ... x48 Black Hair Black Hair ... x17 Red Hair ... x4 Blonde ... x31,
Will still yield a 1 in 4 of all the outputs.

The explicit goal with this is to implement lists where x,y,z only has a small chance of happening due to a neutral term i.e. hair x95 ribbon x4 hairpin x1 would make it so that 4% of prompts have a ribbon, and 1% have a hairpin, all 100 results involve a person with hair, so the impact to the prompt is almost nominal, but this implementation can lead to less chaotic outputs when using a large degree of dynamic prompting for some wildcard lists.

I'd like to be able to statistically represent chances like this one through dynamic prompts, but if there is a way to implement this outside of this plugin, I am open to that as well. Does anyone have an idea of how I can do this? I've read through adieyal's github page's tutorial and syntax as well as the Jinja2 templates but I didn't see anything. Thanks!

akx commented 1 year ago

Your method of duplicating the entries will work if you disable de-duplication, see https://github.com/adieyal/sd-dynamic-prompts#wildcard-settings

There's a PR for an actual weighting syntax, but I'm waiting for @adieyal's input on it: https://github.com/adieyal/dynamicprompts/pull/97