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

[Bug]: DecompressionBombError using X/Y/Z script

Open lucidyan opened this issue 2 years ago • 1 comments
trafficstars

Is there an existing issue for this?

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

What happened?

When you are get large amount of combinations in X/Y/Z script, you'll get an error like this:

PIL.Image.DecompressionBombError: Image size (231258240 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.

This is protection from underlying Pillow library and the reasons described here: https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.open

Possible solutions:

  • Disable check by setting PIL.Image.MAX_IMAGE_PIXELS=None (cons that grid can generate huge unusable images)
  • Split large grids to chunks

Steps to reproduce the problem

  1. Go to txt2img tab
  2. Select X/Y/Z script
  3. Enter a large number of parameters, e.g
  • Steps: 1
  • Seed: 1-100000

What should have happened?

Grid should be generated

Commit where the problem happens

0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8

What platforms do you use to access the UI ?

No response

What browsers do you use to access the UI ?

No response

Command Line Arguments

Any

List of extensions

Any

Console logs

Traceback (most recent call last):
  File "/stable-diffusion-webui/modules/call_queue.py", line 56, in f
    res = list(func(*args, **kwargs))
  File "/stable-diffusion-webui/modules/call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "/stable-diffusion-webui/modules/txt2img.py", line 53, in txt2img
    processed = modules.scripts.scripts_txt2img.run(p, *args)
  File "/stable-diffusion-webui/modules/scripts.py", line 376, in run
    processed = script.run(p, *script_args)
  File "/stable-diffusion-webui/scripts/xyz_grid.py", line 596, in run
    processed, sub_grids = draw_xyz_grid(
  File "/stable-diffusion-webui/scripts/xyz_grid.py", line 309, in draw_xyz_grid
    z_grid = images.draw_grid_annotations(z_grid, sub_grid_size[0], sub_grid_size[1], title_texts, [[images.GridAnnotation()]])
  File "/stable-diffusion-webui/modules/images.py", line 206, in draw_grid_annotations
    cell = im.crop((width * col, height * row, width * (col+1), height * (row+1)))
  File "/stable-diffusion-webui/venv/lib/python3.10/site-packages/PIL/Image.py", line 1234, in crop
    return self._new(self._crop(self.im, box))
  File "stable-diffusion-webui/venv/lib/python3.10/site-packages/PIL/Image.py", line 1252, in _crop
    _decompression_bomb_check(absolute_values)
  File "/stable-diffusion-webui/venv/lib/python3.10/site-packages/PIL/Image.py", line 3164, in _decompression_bomb_check
    raise DecompressionBombError(msg)
PIL.Image.DecompressionBombError: Image size (231258240 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.

Additional information

No response

lucidyan avatar Feb 27 '23 09:02 lucidyan