From a2007b6108b789a6c3e8043a980c2cad13f6b1ad Mon Sep 17 00:00:00 2001 From: AngelBottomless Date: Sat, 17 Aug 2024 13:37:03 +0900 Subject: [PATCH] Fix using wrong values for WEBP format caching --- toolkit/dataloader_mixins.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/toolkit/dataloader_mixins.py b/toolkit/dataloader_mixins.py index df1784e1..e5f8b6ae 100644 --- a/toolkit/dataloader_mixins.py +++ b/toolkit/dataloader_mixins.py @@ -455,10 +455,16 @@ def load_and_process_image( # throw error, they should match print( f"unexpected values: w={w}, h={h}, file_item.scale_to_width={self.scale_to_width}, file_item.scale_to_height={self.scale_to_height}, file_item.path={self.path}") + self.scale_to_width, self.scale_to_height = max(self.scale_to_height, self.scale_to_width), min(self.scale_to_height, self.scale_to_width) + self.crop_width, self.crop_height = max(self.crop_width, self.crop_height), min(self.crop_width, self.crop_height) + self.crop_x, self.crop_y = max(self.crop_x, self.crop_y), min(self.crop_x, self.crop_y) elif h > w and self.scale_to_height < self.scale_to_width: # throw error, they should match print( f"unexpected values: w={w}, h={h}, file_item.scale_to_width={self.scale_to_width}, file_item.scale_to_height={self.scale_to_height}, file_item.path={self.path}") + self.scale_to_width, self.scale_to_height = min(self.scale_to_height, self.scale_to_width), max(self.scale_to_height, self.scale_to_width) + self.crop_width, self.crop_height = min(self.crop_width, self.crop_height), max(self.crop_width, self.crop_height) + self.crop_x, self.crop_y = min(self.crop_x, self.crop_y), max(self.crop_x, self.crop_y) if self.flip_x: # do a flip