Fixed issue with omitting square pictures

This commit is contained in:
Jaret Burkett
2023-08-30 15:00:22 -06:00
parent 33267e117c
commit addf024630

View File

@@ -105,8 +105,13 @@ class BucketsMixin:
# determine new resolution to have the same number of pixels # determine new resolution to have the same number of pixels
current_pixels = width * height current_pixels = width * height
if current_pixels == total_pixels: if current_pixels == total_pixels:
# no change file_item.scale_to_width = width
continue file_item.scale_to_height = height
file_item.crop_width = width
file_item.crop_height = height
new_width = width
new_height = height
else:
aspect_ratio = width / height aspect_ratio = width / height
new_height = int(math.sqrt(total_pixels / aspect_ratio)) new_height = int(math.sqrt(total_pixels / aspect_ratio))
@@ -154,7 +159,8 @@ class BucketsMixin:
# print the buckets # print the buckets
self.build_batch_indices() self.build_batch_indices()
print(f'Bucket sizes for {self.__class__.__name__}:') name = f"{os.path.basename(self.dataset_path)} ({self.resolution})"
print(f'Bucket sizes for {self.dataset_path}:')
for key, bucket in self.buckets.items(): for key, bucket in self.buckets.items():
print(f'{key}: {len(bucket.file_list_idx)} files') print(f'{key}: {len(bucket.file_list_idx)} files')
print(f'{len(self.buckets)} buckets made') print(f'{len(self.buckets)} buckets made')