Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#135 fix: aspect ratio handling on exif_transpose #138

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion toolkit/dataloader_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,11 @@ def load_and_process_image(
return
try:
img = Image.open(self.path)
pre_width, pre_height = img.size
img = exif_transpose(img)
if pre_width != img.width or pre_height != img.height:
self.scale_to_height, self.scale_to_width = self.scale_to_width, self.scale_to_height

except Exception as e:
print(f"Error: {e}")
print(f"Error loading image: {self.path}")
Expand All @@ -453,7 +457,7 @@ def load_and_process_image(
w, h = img.size
if w > h and self.scale_to_width < self.scale_to_height:
# throw error, they should match
print(
raise ValueError(
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}")
elif h > w and self.scale_to_height < self.scale_to_width:
# throw error, they should match
Expand Down