-
Notifications
You must be signed in to change notification settings - Fork 178
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
MLX error: [reshape] Cannot reshape array of size 481656 into shape (1,2,3,16,2,14,7,2,14) #200
Comments
Any progress on this? I haven't been able to reproduce it myself, but maybe we have different model phones. What resolution image are you seeing this with? |
I have reproduced this on commit On MacOS 15.2 (24C101)
Using this image: (Data URL version of image here in case Github modifies the image file: https://gist.githubusercontent.com/deet/3e0ba4f8a2e21a0545067faf3ff14714/raw/3300f82904607c12425c513371430372a0924b59/gistfile1.txt ) |
I wonder if it is related to this item @DePasqualeOrg found: #222 (comment) |
Oh, you mentioned you were using that commit :-) OK, we have a repro I can track it down. |
OK, so with the commit from #222: let scale = min(size.width / extent.width, size.height / extent.height) we have:
That produces this image after the crop:
which isn't quite what we want. Ideally we would want the original image scaled into an image at least as large as the target and cropped to exactly the target. |
We can use a unit test for this: func testResize() {
// resampleBicubic should produce an image with the desired dimensions
let inputFilter = CIFilter(name: "CIConstantColorGenerator")!
inputFilter.setValue(CIColor.red, forKey: "inputColor")
let input = inputFilter.outputImage!.cropped(to: CGRect(x: 0, y: 0, width: 1536, height: 1106))
let target = CGSize(width: 1540, height: 1120)
let output = MediaProcessing.resampleBicubic(input, to: target)
XCTAssertEqual(output.extent.size, target)
} |
If we revert the change from #222 (regarding size) we get exactly what I think we should get:
The extent is larger because the bicubic has extent 3 pixels out on each edge -- the is the exact size we were looking for. So I think we need to go back to the image that triggered the change @DePasqualeOrg you mentioned a portrait image -- what were the dimensions?
|
I think previously it would crash when the width was less than the height, because the image wasn't being resized. I fixed this in the latest commit that's being tested here, but now I've also replicated the crash with a PNG screenshot. |
I made some more changes in #222 that seem to fix the issue for Qwen 2 VL and Qwen 2.5 VL. For some reason I could only get it to work with Lanczos resampling and not with bicubic interpolation. Maybe someone smarter than me can get it working with bicubic, or we can rename the method to |
Hi there.
Love this library so far. However it seems like the default VLM example app crashes when selecting a photo from the photo gallery instead of the default image of the flower and the bee. The following error is returned:
This is reproducible when using an image taken with the device camera.
Will look into it and submit a pull request as needed.
The text was updated successfully, but these errors were encountered: