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

adds checks for resulting image size to avoid memory issues

Open vladmandic opened this issue 1 year ago • 2 comments

adds field in Settings -> Saving Images/Grids -> Maximum image size, in megapixels (implemented as shared.opts.img_max_size_mp)

enforces a check inside xyz grid script as that is common place where this issue occurs. on error, results will be none and error will be printed in webui (using infotext).

closes #8051 closes #8164

vladmandic avatar Feb 27 '23 22:02 vladmandic

I would suggest this be added to common code, Last week I ran into this error without using the xyz grid script, when I did an extremely large batch (800 images, 858MB, 37120x20160, 748.34 Megapixel Grid Image) and attempted to zip the result.

In many ways, I think it would also be useful if the grid image could just be split every 100 images or so, creating multiple grids for extra large batches, as well as an option to skip zipping the grid image itself when zipping batches.

Cyberbeing avatar Mar 02 '23 00:03 Cyberbeing

fair point. i'll take a look at that as well, but lets get this comited first.

vladmandic avatar Mar 02 '23 00:03 vladmandic

The intended approach is to throw rather than return something. Do this with assert.

AUTOMATIC1111 avatar Mar 11 '23 09:03 AUTOMATIC1111

I modified image.py to generate big grid images :D

FurkanGozukara avatar Mar 11 '23 10:03 FurkanGozukara

The intended approach is to throw rather than return something. Do this with assert.

done.

vladmandic avatar Mar 11 '23 13:03 vladmandic

What's with this change? The error message is twice the set value and even generating a 2x1 64px grid far exceeds the default value.

DecompressionBombError: Image size (4096 pixels) exceeds limit of 440.00000000000006 pixels, could be decompression bomb DOS attack.

NSQY avatar Mar 11 '23 14:03 NSQY

I set MAX_IMAGE_PIXELS to None in PIL/Image.py :), that's work

Doujiang2333 avatar Mar 12 '23 03:03 Doujiang2333