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

fix: upload failure due to non-rgb image #335

Merged
merged 6 commits into from
Aug 27, 2024
Merged

fix: upload failure due to non-rgb image #335

merged 6 commits into from
Aug 27, 2024

Conversation

zanussbaum
Copy link
Collaborator

@zanussbaum zanussbaum commented Aug 26, 2024

🚀 This description was created by Ellipsis for commit b5c4e67

Summary:

Fixes image upload failures by converting non-RGB images to RGB format in nomic/dataset.py.

Key points:

  • Fixes image upload failures in nomic/dataset.py.
  • Converts non-RGB images to RGB format in the _add_blobs function.
  • Ensures all images are in RGB format to prevent upload failures.

Generated with ❤️ by ellipsis.dev

# Auto resize to max 512x512
image = Image.open(blob)
image = image.convert("RGB")
if image.height > 512 or image.width > 512:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resizing logic should maintain the aspect ratio. Consider using image.thumbnail((512, 512), Image.ANTIALIAS) to resize while maintaining the aspect ratio.

Copy link
Collaborator

@bmschmidt bmschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, note on pathlib.

nomic/dataset.py Outdated
@@ -1420,6 +1421,7 @@ def _add_blobs(
elif isinstance(blob, bytes):
images.append((uuid, blob))
elif isinstance(blob, Image.Image):
image = image.convert("RGB")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion of images to RGB format is repeated in the _add_blobs function. Consider refactoring to avoid this repetition.

@zanussbaum zanussbaum merged commit 3358a0e into main Aug 27, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants