aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGugubo <29143981+Gugubo@users.noreply.github.com>2022-10-14 12:19:39 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2022-10-14 16:54:24 +0000
commit2fb9891af3bb4c36a6de6b44937e927bda43c10d (patch)
tree9e25568d1fcb79a1f63511f2c838d0040ab25951
parent6c6427946087d761d548d97164594d914fdd9b78 (diff)
downloadstable-diffusion-webui-gfx803-2fb9891af3bb4c36a6de6b44937e927bda43c10d.tar.gz
stable-diffusion-webui-gfx803-2fb9891af3bb4c36a6de6b44937e927bda43c10d.tar.bz2
stable-diffusion-webui-gfx803-2fb9891af3bb4c36a6de6b44937e927bda43c10d.zip
Change grid row count autodetect to prevent empty spots
Instead of just rounding (sometimes resulting in grids with "empty" spots), find a divisor. For example: 8 images will now result in a 4x2 grid instead of a 3x3 with one empty spot.
-rw-r--r--modules/images.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/images.py b/modules/images.py
index 68cdbc93..90eca37a 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -25,8 +25,9 @@ def image_grid(imgs, batch_size=1, rows=None):
elif opts.n_rows == 0:
rows = batch_size
else:
- rows = math.sqrt(len(imgs))
- rows = round(rows)
+ rows = math.floor(math.sqrt(len(imgs)))
+ while len(imgs) % rows != 0:
+ rows -= 1
cols = math.ceil(len(imgs) / rows)