Repository: AUTOMATIC1111/stable-diffusion-webui

Issue:
Keep -1 for seeds on X/Y plot checkbox isn't respected.
**Describe the bug**
Keep -1 for seeds on X/Y plot checkbox isn't respected

**To Reproduce**
Steps to reproduce the behavior:
1. txt2img
2. use Script, X/Y Plot, enter values, check "Keep -1 for seeds on X/Y plot"
3. Generate
4. See that all the seeds are all the same on both X and Y

**Expected behavior**
New seed for each image generated


**Desktop (please complete the following information):**
 - OS: Windows
 - Browser: Edge
 - ca3e5519e8b6dc020c5e7ae508738afb5dc6f3ec


Keep -1 for seeds on X/Y plot checkbox isn't respected.
**Describe the bug**
Keep -1 for seeds on X/Y plot checkbox isn't respected

**To Reproduce**
Steps to reproduce the behavior:
1. txt2img
2. use Script, X/Y Plot, enter values, check "Keep -1 for seeds on X/Y plot"
3. Generate
4. See that all the seeds are all the same on both X and Y

**Expected behavior**
New seed for each image generated


**Desktop (please complete the following information):**
 - OS: Windows
 - Browser: Edge
 - ca3e5519e8b6dc020c5e7ae508738afb5dc6f3ec




Discussion:
It actually matters only for "Seed" axis, and completely ignored for anything else!

If you want ALL of cells have different seed, you can make a copy of `scripts/xy_grid.py`, rename it to `xy_grid_seed.py` and edit the file.

You'll have to change `return "X/Y plot"` (next to `def title(self):`) to `return "X/Y plot (random seed)"` (it's just the name of the script), and comment out `modules.processing.fix_seed(p)` (next to `def run`), changing it to `#modules.processing.fix_seed(p)`

It worked for me today!
To retrieve the actual seed of generated images, you can refer to filenames in `outputs/txt2img-images/` (or `outputs/img2img-images/`), where individual images will be saved.

P.S.
Don't forget to restart the server (close console) after you change the scripts.
Then choose "X/Y plot (random seed)" instead of "X/Y plot" in UI.
Got hit by this, too.  A better fix is:

    if not no_fixed_seeds:
        modules.processing.fix_seed(p)

That keeps the seed as -1 only if the checkbox is selected. No need to recreate the title for a new script or anything like that. The `process_images` sub will call `fix_seed` later on, but only on the `pc` cell-copied object.
It actually matters only for "Seed" axis, and completely ignored for anything else!

If you want ALL of cells have different seed, you can make a copy of `scripts/xy_grid.py`, rename it to `xy_grid_seed.py` and edit the file.

You'll have to change `return "X/Y plot"` (next to `def title(self):`) to `return "X/Y plot (random seed)"` (it's just the name of the script), and comment out `modules.processing.fix_seed(p)` (next to `def run`), changing it to `#modules.processing.fix_seed(p)`

It worked for me today!
To retrieve the actual seed of generated images, you can refer to filenames in `outputs/txt2img-images/` (or `outputs/img2img-images/`), where individual images will be saved.

P.S.
Don't forget to restart the server (close console) after you change the scripts.
Then choose "X/Y plot (random seed)" instead of "X/Y plot" in UI.
Got hit by this, too.  A better fix is:

    if not no_fixed_seeds:
        modules.processing.fix_seed(p)

That keeps the seed as -1 only if the checkbox is selected. No need to recreate the title for a new script or anything like that. The `process_images` sub will call `fix_seed` later on, but only on the `pc` cell-copied object.

Resolving patch:
diff --git a/scripts/xy_grid.py b/scripts/xy_grid.py
--- a/scripts/xy_grid.py
+++ b/scripts/xy_grid.py
@@ -190,7 +190,9 @@ def ui(self, is_img2img):
         return [x_type, x_values, y_type, y_values, draw_legend, no_fixed_seeds]
 
     def run(self, p, x_type, x_values, y_type, y_values, draw_legend, no_fixed_seeds):
-        modules.processing.fix_seed(p)
+        if not no_fixed_seeds:
+            modules.processing.fix_seed(p)
+
         p.batch_size = 1
 
         def process_axis(opt, vals):


Test patch: