Merge pull request #1008 from Cauldrath/zero_height_error

Fix zero height buckets
This commit is contained in:
Kohya S
2023-12-20 22:09:04 +09:00
committed by GitHub

View File

@@ -1307,19 +1307,19 @@ def load_vae(vae_id, dtype):
def make_bucket_resolutions(max_reso, min_size=256, max_size=1024, divisible=64): def make_bucket_resolutions(max_reso, min_size=256, max_size=1024, divisible=64):
max_width, max_height = max_reso max_width, max_height = max_reso
max_area = (max_width // divisible) * (max_height // divisible) max_area = max_width * max_height
resos = set() resos = set()
size = int(math.sqrt(max_area)) * divisible width = int(math.sqrt(max_area) // divisible) * divisible
resos.add((size, size)) resos.add((width, width))
size = min_size width = min_size
while size <= max_size: while width <= max_size:
width = size height = min(max_size, int((max_area // width) // divisible) * divisible)
height = min(max_size, (max_area // (width // divisible)) * divisible) if height > 0:
resos.add((width, height)) resos.add((width, height))
resos.add((height, width)) resos.add((height, width))
# # make additional resos # # make additional resos
# if width >= height and width - divisible >= min_size: # if width >= height and width - divisible >= min_size:
@@ -1329,7 +1329,7 @@ def make_bucket_resolutions(max_reso, min_size=256, max_size=1024, divisible=64)
# resos.add((width, height - divisible)) # resos.add((width, height - divisible))
# resos.add((height - divisible, width)) # resos.add((height - divisible, width))
size += divisible width += divisible
resos = list(resos) resos = list(resos)
resos.sort() resos.sort()