Commit 2fb9891a authored by Gugubo's avatar Gugubo Committed by AUTOMATIC1111

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.
parent 6c642794
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment