Skip to content

Bug: Combinatorial Generation: Inflated Image Counts and Identical Duplicates #2

@Adios

Description

@Adios

Bug: Combinatorial Generation: Inflated Image Counts and Identical Duplicates

High-Level Summary:
The "Combinatorial generation" feature currently suffers from a critical bug in how it calculates the number of prompts and how it structures the prompt list. This results in the generation of significantly more images than requested and creates identical duplicate images when using fixed seeds.

This summary, diagnosed with the help of Google's Gemini 2.5 Pro, details the issues and proposes a fix.

The Core Problems:

  1. Inflated Image Counts (The B*B Bug):
    The number of prompts generated is incorrectly calculated as (Num_Combinations * Combinatorial_Batches * Combinatorial_Batches).

    • Expected: If you have 8 combinations and set "Combinatorial batches" to 3, you expect 24 images (8 * 3).
    • Actual: The system generates 72 images (8 * 3 * 3).
  2. Malformed List Structure (The Duplication Bug):
    The underlying list of prompts is structured incorrectly as [P1, P1, P2, P2, ...].

    • The extension's internal seeding logic generates seeds in blocks like [S, S, S+1, S+1].
    • When these combine, you get (P1, S) and (P1, S), resulting in identical duplicate images.
    • Expected Structure: The list should be [P1, P2, P1, P2, ...] to ensure that P1 gets seed S and the next P1 gets seed S+1.

Technical Details & Suggested Fix:

The issue appears to stem from the underlying library returning a prompt list that is both too long and ordered incorrectly for the extension's seeding logic.

To resolve this without altering the extension's core design (where it overrides the main UI batch controls), the fix should be applied in sd_dynamic_prompts/dynamic_prompting.py. The logic needs to intercept the prompt list returned by the generator and perform the following corrections before passing it to the Web UI:

  1. Trim the inflated list to the correct length (Combinations * Batches) to resolve the count bug.
  2. De-duplicate/Reorder the list to enforce the correct [P1, P2, P1, P2...] structure.

This approach would ensure:

  • The total image count is exactly what the user requested (Combinations * Batches).
  • Every generated image is a unique combination of Prompt and Seed (no identical duplicates).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions