Skip to content

added image resize config for MLX vision input#636

Merged
tpae merged 2 commits intoosaurus-ai:mainfrom
RaajeevChandran:bugfix/resize-image-mlx-vision-models
Mar 14, 2026
Merged

added image resize config for MLX vision input#636
tpae merged 2 commits intoosaurus-ai:mainfrom
RaajeevChandran:bugfix/resize-image-mlx-vision-models

Conversation

@RaajeevChandran
Copy link
Contributor

Summary

enforce a fixed image resize config for MLX vision models to avoid fatal crash due to maximum allowed buffer size. fixes #634

Test Plan

  1. Select an MLX vision model
  2. Select a high resolution image and tap send
  3. The app must run without crashing

Checklist

  • I have read CONTRIBUTING.md
  • I added/updated tests where reasonable
  • I updated docs/README as needed
  • I verified build on macOS with Xcode 16.4+

@tpae
Copy link
Contributor

tpae commented Mar 14, 2026

Would it resize all images to a square?

@RaajeevChandran
Copy link
Contributor Author

Yes. That's intentional because I have the exact same config for one of my iOS apps that uses MLX. Using a square size config not only resolved the crash but also reduced the model response time. Afaik there won't be any issues for the models to process the image.

Attaching a few test cases here:

  1. high res landscape image (6000x2848)
image
  1. low res portrait image (960x1280)
image

@tpae
Copy link
Contributor

tpae commented Mar 14, 2026

I see. What about smaller images? will it upscale it?

@RaajeevChandran
Copy link
Contributor Author

Yes, small images would get upscaled due to how MediaProcessing.apply in MLXVLM works since it doesn't clamp the scale to 1.0. The impact is negligible in practice but I've gone ahead and addressed it anyway by pre processing images before they reach the library. Small images now pass through at their native resolution while large images still get downscaled as intended

@tpae
Copy link
Contributor

tpae commented Mar 14, 2026

Looks great! Thank you for your contribution!

@tpae tpae merged commit 217b47c into osaurus-ai:main Mar 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fatal crash when a high res image is selected in MLX vision models

2 participants