Repository: AUTOMATIC1111/stable-diffusion-webui

Issue:
[Bug]: xyz script fails to update x dimension
### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

I'm trying to compare checkpoints (z dimension) on a x (photo, 3d, anime) vs y (subjects) grid.

I saved 3 styles and 3 subjects and called the script against 2 checkpoints

This is the result

![xyz_grid-0001-1131235204-e6e99610c4-3840x1864](https://user-images.githubusercontent.com/4661737/215094307-e85569e4-6f58-47ae-ac7a-cd1d54a90f08.png)

when switching x with y

![xyz_grid-0002-1131235204-e6e99610c4-3840x2710](https://user-images.githubusercontent.com/4661737/215095803-17a48c32-aa90-403e-a5ea-fe84c0e59780.png)

so y and z work fine, x doesn't

### Steps to reproduce the problem

1. Add 6 new styles: photo, 3d, anime, person, organic, urban defined as
```
photo,"DSLR RAW filmgrain photo, shot on iphone, photography, edited in Adobe Lightroom","anime, illustration, 3d, octane render, drawing, cell shading, semi-realistic, cgi, sketch, cartoon"
3d,"3d octane render, unreal engine raytraced screenshot, cgi, photorealistic","photo, DSLR, cell shading, anime, illustration, drawing, sketch, cartoon"
anime,"anime absurdres illustration, drawing, lineart","photo, DSLR, 3d, cell shading, octane render, cgi, unreal engine"
person,"woman sleeping slumped over in the rain during the nighttime festival, wet hair, perfect anatomy","ugly, old, nsfw, big breasts, bad hands"
organic,"ancient giant tree in the deep jungle, birds in the branches, fog at dawn, beautiful scenery","interior"
urban,"modern skyscraper towering over an old abandoned medieval town, sheds and taverns, storm clouds, urban setting","rural, portrait"
```
2. setup xyz grid using person, organic and urban as style x and photo, 3d and anime as style y. For z pick two checkpoints
3. launch generation
4. have a look at the grid

### What should have happened?

I should get something like this where all the images are different, not the same across one dimension

![](https://i.imgur.com/Nce9Asn.jpg)

### Commit where the problem happens

9beb794e0b0dc1a0f9e89d8e38bd789a8c608397

### What platforms do you use to access UI ?

Linux

### What browsers do you use to access the UI ?

Mozilla Firefox

### Command Line Arguments

```Shell
--share --enable-insecure-extension-access
```


### Additional information, context and logs

_No response_


Discussion:
I will see if I can modify the code but currently if you use two of the same axes (such as "Styles") in xyz grid script (or the old xy script for matter), only one of them gets applied.

> ![](https://camo.githubusercontent.com/bb67c8406c51f8aead9c0f715c3eabe34aeaf5798865e9c0a2af5cb67abe39cc/68747470733a2f2f692e696d6775722e636f6d2f4e63653941736e2e6a7067)

This image you sent does not use two "Styles" axii, it uses a style axis, checkpoint axis and the top z axis is a Prompt S/R axis (otherwise the top axis would say "Styles: Car", "Styles: Urban", etc.)

thanks for the quick reply!

I see...

how do you switch between saved styles in prompt s/r? is there any keyword?
say something like `style:<my saved style name>` to be added inside the prompt
Just as an added comment, it would be very useful to be able to use two of the same axes, especially for this case, as you could then see the effect of combining styles

Resolving patch:
diff --git a/scripts/xyz_grid.py b/scripts/xyz_grid.py
--- a/scripts/xyz_grid.py
+++ b/scripts/xyz_grid.py
@@ -123,7 +123,7 @@ def apply_vae(p, x, xs):
 
 
 def apply_styles(p: StableDiffusionProcessingTxt2Img, x: str, _):
-    p.styles = x.split(',')
+    p.styles.extend(x.split(','))
 
 
 def format_value_add_label(p, opt, x):
@@ -499,7 +499,7 @@ def fix_axis_seeds(axis_opt, axis_list):
         image_cell_count = p.n_iter * p.batch_size
         cell_console_text = f"; {image_cell_count} images per cell" if image_cell_count > 1 else ""
         plural_s = 's' if len(zs) > 1 else ''
-        print(f"X/Y plot will create {len(xs) * len(ys) * len(zs) * image_cell_count} images on {len(zs)} {len(xs)}x{len(ys)} grid{plural_s}{cell_console_text}. (Total steps to process: {total_steps})")
+        print(f"X/Y/Z plot will create {len(xs) * len(ys) * len(zs) * image_cell_count} images on {len(zs)} {len(xs)}x{len(ys)} grid{plural_s}{cell_console_text}. (Total steps to process: {total_steps})")
         shared.total_tqdm.updateTotal(total_steps)
 
         grid_infotext = [None]
@@ -533,6 +533,7 @@ def cell(x, y, z):
                 return Processed(p, [], p.seed, "")
 
             pc = copy(p)
+            pc.styles = pc.styles[:]
             x_opt.apply(pc, x, xs)
             y_opt.apply(pc, y, ys)
             z_opt.apply(pc, z, zs)


Test patch: