stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Feature Request]: Option for not having a grid for X/Y/Z Plot

Open micky2be opened this issue 1 year ago • 15 comments

Is there an existing issue for this?

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

What would your feature do ?

I sometime want to generate a bunch of images from X/Y/Z plot system, although I don't need a grid. And more importantly, the grid image has a limit of 200 MP which is blocking me from running different tests. It's also weird there are option for batch grids, which do not apply to this one.

Proposed workflow

  1. Go to Script
  2. Select X/Y/Z Plot
  3. Uncheck the option to create a grid

Additional information

No response

micky2be avatar Apr 05 '23 19:04 micky2be

You can disable saving grids and increase the resolution limit in settings (Saving images/grids).

missionfloyd avatar Apr 07 '23 09:04 missionfloyd

For the file size, yes. For turning off the grid, no. sure, it works for batches, but it's not applied for X/Y/Z plot. And couldn't find anything in the code to suggest there is such option. That, or I'm blind.

micky2be avatar Apr 07 '23 12:04 micky2be

X/Y/Z plot uses the same setting. https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/22bcc7be428c94e9408f589966c2040187245d81/scripts/xyz_grid.py#L669-L675 https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/22bcc7be428c94e9408f589966c2040187245d81/modules/shared.py#L231

missionfloyd avatar Apr 08 '23 03:04 missionfloyd

This is the setting to save the image, not the generation of the image. The grid will always generate no matter the option selected.

micky2be avatar Apr 09 '23 10:04 micky2be

I am struggling with the same issue... want to rotate a prompt through 600 checkpoints to see what models might work best for me... and every time I run into memory allocation issues as the grid generates internally... machine crashes before he could even consider NOT saving....

TheOnlyHolyMoly avatar May 14 '23 22:05 TheOnlyHolyMoly

This is an interesting idea, and, the last I looked at that script, very easy to implement. Even if only a couple people would need it, I think it's maybe 3 lines of code?

Then again, the script also needs better error handling and recovery anyways; would it be acceptable if the primary grid generation just failed gracefully and presented the images it collected?

DejitaruJin avatar Jun 15 '23 22:06 DejitaruJin

SD.next actually already has this feature implemented in the XYZ script. @automatic1111 would just need to pull that into main branch.

TheOnlyHolyMoly avatar Jun 20 '23 10:06 TheOnlyHolyMoly

yes please @AUTOMATIC1111 include this option, would be so helpful as you can create really cool videos with the xy plot script where the grid is just hindering..

paintbot avatar Jul 03 '23 19:07 paintbot

While you're waiting for this feature to land, make the following changes to xyz_grid.py:

Look for following code:

        grid = images.image_grid(processed_result.images[start_index:end_index], rows=len(ys))
        if draw_legend:
            grid = images.draw_grid_annotations(grid, processed_result.images[start_index].size[0], processed_result.images[start_index].size[1], hor_texts, ver_texts, margin_size)
        processed_result.images.insert(i, grid)

Modify it as follows:

        # grid = images.image_grid(processed_result.images[start_index:end_index], rows=len(ys))
        if draw_legend:
            # grid = images.draw_grid_annotations(grid, processed_result.images[start_index].size[0], processed_result.images[start_index].size[1], hor_texts, ver_texts, margin_size)
            pass
        # processed_result.images.insert(i, grid)

Similarly, look for the following code:

    z_grid = images.image_grid(processed_result.images[:z_count], rows=1)
    if draw_legend:
        z_grid = images.draw_grid_annotations(z_grid, sub_grid_size[0], sub_grid_size[1], title_texts, [[images.GridAnnotation()]])
    processed_result.images.insert(0, z_grid)

Modify it as follows:

    # z_grid = images.image_grid(processed_result.images[:z_count], rows=1)
    if draw_legend:
        # z_grid = images.draw_grid_annotations(z_grid, sub_grid_size[0], sub_grid_size[1], title_texts, [[images.GridAnnotation()]])
        pass
    # processed_result.images.insert(0, z_grid)

Comment out the assertion that causes the script to fail:

# assert grid_mp < opts.img_max_size_mp, f'Error: Resulting grid would be too large ({grid_mp} MPixels) (max configured size is {opts.img_max_size_mp} MPixels)'

You can now enjoy x/y/z without generating or saving the grid.

dejayc avatar Jul 13 '23 06:07 dejayc

While you're waiting for this feature to land, make the following changes to xyz_grid.py:

Look for following code:

        grid = images.image_grid(processed_result.images[start_index:end_index], rows=len(ys))
        if draw_legend:
            grid = images.draw_grid_annotations(grid, processed_result.images[start_index].size[0], processed_result.images[start_index].size[1], hor_texts, ver_texts, margin_size)
        processed_result.images.insert(i, grid)

Modify it as follows:

        # grid = images.image_grid(processed_result.images[start_index:end_index], rows=len(ys))
        if draw_legend:
            # grid = images.draw_grid_annotations(grid, processed_result.images[start_index].size[0], processed_result.images[start_index].size[1], hor_texts, ver_texts, margin_size)
            pass
        # processed_result.images.insert(i, grid)

Similarly, look for the following code:

    z_grid = images.image_grid(processed_result.images[:z_count], rows=1)
    if draw_legend:
        z_grid = images.draw_grid_annotations(z_grid, sub_grid_size[0], sub_grid_size[1], title_texts, [[images.GridAnnotation()]])
    processed_result.images.insert(0, z_grid)

Modify it as follows:

    # z_grid = images.image_grid(processed_result.images[:z_count], rows=1)
    if draw_legend:
        # z_grid = images.draw_grid_annotations(z_grid, sub_grid_size[0], sub_grid_size[1], title_texts, [[images.GridAnnotation()]])
        pass
    # processed_result.images.insert(0, z_grid)

Comment out the assertion that causes the script to fail:

# assert grid_mp < opts.img_max_size_mp, f'Error: Resulting grid would be too large ({grid_mp} MPixels) (max configured size is {opts.img_max_size_mp} MPixels)'

You can now enjoy x/y/z without generating or saving the grid.

No, that will result in many errors which make things break apart.

@AUTOMATIC1111 , this should be the commit which adds this: Commit Would love to see this implemented. My PC occasionally crashes from 500+ images getting put on one massive canvas.

wynandhuizinga avatar Oct 09 '23 10:10 wynandhuizinga

Any update?

alexdosa92 avatar Nov 24 '23 13:11 alexdosa92

I am struggling with the same issue... want to rotate a prompt through 600 checkpoints to see what models might work best for me... and every time I run into memory allocation issues as the grid generates internally... machine crashes before he could even consider NOT saving....

I have exactly the same problem. For me, it is simply impossible to run the prompt through checkpoints, limited as it is to 200 megapixels. I don’t need this collage at all. It’s incredible that there isn’t even an option to run a prompt without artificial limitations.

Shurale7 avatar Jan 10 '24 09:01 Shurale7

@Shurale7 feel free to use my alternative solution

micky2be avatar Jan 10 '24 09:01 micky2be

While you're waiting for this feature to land, make the following changes to xyz_grid.py:

Look for following code:

        grid = images.image_grid(processed_result.images[start_index:end_index], rows=len(ys))
        if draw_legend:
            grid = images.draw_grid_annotations(grid, processed_result.images[start_index].size[0], processed_result.images[start_index].size[1], hor_texts, ver_texts, margin_size)
        processed_result.images.insert(i, grid)

Modify it as follows:

        # grid = images.image_grid(processed_result.images[start_index:end_index], rows=len(ys))
        if draw_legend:
            # grid = images.draw_grid_annotations(grid, processed_result.images[start_index].size[0], processed_result.images[start_index].size[1], hor_texts, ver_texts, margin_size)
            pass
        # processed_result.images.insert(i, grid)

Similarly, look for the following code:

    z_grid = images.image_grid(processed_result.images[:z_count], rows=1)
    if draw_legend:
        z_grid = images.draw_grid_annotations(z_grid, sub_grid_size[0], sub_grid_size[1], title_texts, [[images.GridAnnotation()]])
    processed_result.images.insert(0, z_grid)

Modify it as follows:

    # z_grid = images.image_grid(processed_result.images[:z_count], rows=1)
    if draw_legend:
        # z_grid = images.draw_grid_annotations(z_grid, sub_grid_size[0], sub_grid_size[1], title_texts, [[images.GridAnnotation()]])
        pass
    # processed_result.images.insert(0, z_grid)

Comment out the assertion that causes the script to fail:

# assert grid_mp < opts.img_max_size_mp, f'Error: Resulting grid would be too large ({grid_mp} MPixels) (max configured size is {opts.img_max_size_mp} MPixels)'

You can now enjoy x/y/z without generating or saving the grid.

For those that wish to utilize this solution, take the advice above but instead of modifying the existing xyz_grid.py, copy the file and name it something else, and find the line: class Script(scripts.Script): def title(self): return "X/Y/Z plot"

and modify the return value to give it a new discreet name in the drop-down list in the gui:

class Script(scripts.Script): def title(self): return "X/Y/Z plot NO GRID"

after both of these edits are complete, exit automatic1111 and be absolutely sure to close any open UI as these lists are cached and you will get errors if you try to generate from a page with old scripts cached.

Creating a new script with the edits and naming it as such allows you to freely select a grid-less xyz plot at will, and leaves the grid-generating one for you to return to, without modifying the .py again.

I've tested this successfully on v1.9.3

EchoHeadache avatar Apr 26 '24 17:04 EchoHeadache