EveryDream-trainer/ldm/data/aspects.py

93 lines
3.2 KiB
Python

ASPECTS5 = [[768,768], # 589824 1:1
[832,704],[704,832], # 585728 1.181:1
[896,640],[640,896], # 573440 1.4:1
[960,576],[576,960], # 552960 1.6:1
[1024,576],[576,1024], # 524288 1.778:1
[1088,512],[512,1088], # 497664 2.125:1
[1152,512],[512,1152], # 589824 2.25:1
[1216,448],[448,1216], # 552960 2.714:1
[1280,448],[448,1280], # 573440 2.857:1
[1344,384],[384,1344], # 518400 3.5:1
[1408,384],[384,1408], # 540672 3.667:1
[1472,320],[320,1472], # 470400 4.6:1
[1536,320],[320,1536], # 491520 4.8:1
]
ASPECTS4 = [[704,704], # 501,376 1:1
[768,640],[640,768], # 491,520 1.2:1
[832,576],[576,832], # 458,752 1.444:1
[896,512],[512,896], # 458,752 1.75:1
[960,512],[512,960], # 491,520 1.875:1
[1024,448],[448,1024], # 458,752 2.286:1
[1088,448],[448,1088], # 487,424 2.429:1
[1152,384],[384,1152], # 442,368 3:1
[1216,384],[384,1216], # 466,944 3.125:1
[1280,384],[384,1280], # 491,520 3.333:1
[1280,320],[320,1280], # 409,600 4:1
[1408,320],[320,1408], # 450,560 4.4:1
[1536,320],[320,1536], # 491,520 4.8:1
]
ASPECTS3 = [[640,640], # 409600 1:1
[704,576],[576,704], # 405504 1.25:1
[768,512],[512,768], # 393216 1.5:1
[896,448],[448,896], # 401408 2:1
[1024,384],[384,1024], # 393216 2.667:1
[1280,320],[320,1280], # 409600 4:1
[1408,256],[256,1408], # 360448 5.5:1
[1472,256],[256,1472], # 376832 5.75:1
[1536,256],[256,1536], # 393216 6:1
[1600,256],[256,1600], # 409600 6.25:1
]
ASPECTS2 = [[576,576], # 331776 1:1
[640,512],[512,640], # 327680 1.25:1
[640,448],[448,640], # 286720 1.4286:1
[704,448],[448,704], # 314928 1.5625:1
[832,384],[384,832], # 317440 2.1667:1
[1024,320],[320,1024], # 327680 3.2:1
[1280,256],[256,1280], # 327680 5:1
]
ASPECTS = [[512,512], # 262144 1:1
[576,448],[448,576], # 258048 1.29:1
[640,384],[384,640], # 245760 1.667:1
[768,320],[320,768], # 245760 2.4:1
[832,256],[256,832], # 212992 3.25:1
[896,256],[256,896], # 229376 3.5:1
[960,256],[256,960], # 245760 3.75:1
[1024,256],[256,1024], # 245760 4:1
]
ASPECTS_448 = [[448,448], # 200704 1:1
[512,384],[384,512], # 196608 1.333:1
[640,320],[320,640], # 204800 2:1
[768,256],[256,768], # 196608 3:1
]
ASPECTS_384 = [[384,384], # 147456 1:1
[448,320],[320,448], # 143360 1.4:1
[512,256],[256,512], # 131072 2:1
[704,192],[192,704], # 135168 3.667:1
]
ASPECTS_256 = [[256,256], # 65536 1:1
[384,192],[192,384], # 73728 2:1
[512,128],[128,512], # 65536 4:1
]
def get_aspect_buckets(resolution):
if resolution < 256:
raise ValueError("Resolution must be at least 256")
try:
rounded_resolution = int(resolution / 64) * 64
all_image_sizes = __get_all_aspects()
aspects = next(filter(lambda sizes: sizes[0][0]==rounded_resolution, all_image_sizes), None)
return aspects
except Exception as e:
print(f" *** Could not find selected resolution: {rounded_resolution}, check your resolution in config YAML")
raise e
def __get_all_aspects():
return [ASPECTS, ASPECTS2, ASPECTS3, ASPECTS4, ASPECTS5, ASPECTS_448, ASPECTS_384, ASPECTS_256]