8000 [draft] excess image resize maintain aspect ratio by mcembalest · Pull Request #378 · nomic-ai/nomic · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[draft] excess image resize maintain aspect ratio #378

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mcembalest
Copy link
Collaborator
@mcembalest mcembalest commented Mar 7, 2025

Currently images seem to get hard-adjusted to 512,512 if either width or height exceeds 512

image

we have a helper function to resize images while maintaining aspect ratio so this PR re-uses it


Important

Replace hard-coded image resize with resize_pil() to maintain aspect ratio in dataset.py and embed.py.

  • Behavior:
    • Replace hard-coded image resize with resize_pil() in _add_blobs() in dataset.py and image() in embed.py to maintain aspect ratio.
  • Functions:
    • Move resize_pil() from embed.py to utils.py for reuse.
  • Imports:
    • Add resize_pil import to dataset.py and embed.py.

This description was created by Ellipsis for 9aeee9e. It will automatically update as commits are pushed.

max_width = 512
max_height = 512
if width > max_width or height > max_height:
downsize_factor = max(width // max_width, height // max_height)
Copy link
Contributor

Choose a reason for hiding this comment

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

The new helper function resize_pil computes the downsize_factor using integer division (e.g. width // max_width), so for images only slightly above 512 (e.g. 600×700) the factor is 1 and no resizing occurs. Consider computing a floating‑point scale factor (e.g. scale = min(max_width/width, max_height/height)) and then resizing with new dimensions (int(width*scale), int(height*scale)). Also, specify a resampling filter like Image.LANCZOS for better quality.

@mcembalest mcembalest changed the title excess image resize maintain aspect ratio [draft] excess image resize maintain aspect ratio Mar 10, 2025
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.

1 participant
0