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.06k stars 267 forks source link

Combinatorial generation batch > 1 acting wrong #787

Open Zantagor opened 5 months ago

Zantagor commented 5 months ago

Not sure if it's a bug, or me not understanding how this should work. But let's say I have this basic prompt Prompt: Beautiful {dog|house} Negative: ugly with a specific seed.

And I set that Dynamic Prompts On, and Combinatorial Generation on. And I set the Combinatorial Batches to 2 Fixed Seed: On, Unlink seed from Prompt: On

I would expect 4 images. House A, Dog A, House B, Dog B

But what I'm getting instead is House A, House A, Dog A, Dog A, House B, House B, Dog B, Dog B.

basically I would be expecting (2 1) 2 batches... but what it seems to be doing is (2 2) 2 batches.... (it counts the negative twice when building the final set.

I went and added a couple of log.info and dumped the all_prompts and all_negative_prompts, and as I thoughts, theres 8 entries for each. I would've expected at most 4.

To me, this sounds wrong. Or am I missing something?

Zantagor commented 5 months ago

I did end up making a temp fix that works for me in helpers.py just before the generate_prompt_cross_product call, I clean up the negative prompts of duplicates ` all_negative_prompts = list(dict.fromkeys(all_negative_prompts))

if num_prompts is None:
    return generate_prompt_cross_product(all_prompts, all_negative_prompts)`

it might have unforseen issues else where I guess, but for my own purpose, I do not plan on having dynamic negatives, so it fixes my main problem

abctuba commented 5 months ago

I concur with this, I have the same expectation but I am getting the same results.

abctuba commented 5 months ago

I did end up making a temp fix that works for me in helpers.py just before the generate_prompt_cross_product call, I clean up the negative prompts of duplicates ` all_negative_prompts = list(dict.fromkeys(all_negative_prompts))

if num_prompts is None:
    return generate_prompt_cross_product(all_prompts, all_negative_prompts)`

it might have unforseen issues else where I guess, but for my own purpose, I do not plan on having dynamic negatives, so it fixes my main problem

Could you clarify where this helpers.py file is likely located?

Zantagor commented 5 months ago

Sure, https://github.com/adieyal/sd-dynamic-prompts/blob/main/sd_dynamic_prompts/helpers.py

in Automatic1111 that would be in /webui/extensions/sd-dynamic-prompts/sd_dynamic_prompts

I just put all_negative_prompts = list(dict.fromkeys(all_negative_prompts)) before the code block if num_prompts is None: return generate_prompt_cross_product(all_prompts, all_negative_prompts)

SGrahambo commented 1 month ago

I'm having this issue as well. The math appears to be all_prompts*combinatorial_batches*combinatorial_batches, regardless of if the prompts are in the negative or positive or both. So something with 5 total prompts and set to 4 combinatorial batches is 5*4*4=80 total images. So I think that's a good lead to go on.