mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-09 06:45:09 +00:00
Merge pull request #1008 from Cauldrath/zero_height_error
Fix zero height buckets
This commit is contained in:
@@ -1307,17 +1307,17 @@ 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))
|
||||||
|
|
||||||
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user