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

RuntimeError: nonzero is not supported for tensors with more than INT_MAX elements, file a support request #427

Open
harry-esmart opened this issue Jun 9, 2023 · 6 comments

Comments

@harry-esmart
Copy link

I got this error at this line masks = mask_generator.generate(image). What caused the error?

@MikeLilley
Copy link

What size image are you using? I got this error when using images of dimension 4096x3072 but after scaling the x-dimension to 3600, the problem went away. I did further testing with different sized images and it seems that small images do not have any problem, but large images produce this error. Unless I'm missing something, it seems that there's an upper limit to the size of images you can use.

@theFilipko
Copy link

Any updates on that issue? In the paper, chapter 5, section "Images" they state that images are 3300×4950 pixels on average.

@theFilipko
Copy link

May be related to this issue:
I was playing with the Segment Anything Demo on the web. I have an PNG image of size 2661x15711 pixels, 119MB. The max size I could upload to SAM was 2536x14975 pixels. I used GIMP, cubic interpolation. The default PNG compression level is 9. Then I did the same but with the compression level 8 and I could not upload it. The difference between image with the compression 9 and 8 is 8192 bytes size on disk (Windows 10).

@sdlyzhq
Copy link

sdlyzhq commented Jan 8, 2024

I have the same problem, still no response

@heyoeyo
Copy link

heyoeyo commented Jan 8, 2024

This was mentioned in issue #554 and there is an associated fix by the same poster in pull request #569.

If you'd rather not update/modify the code, you can alternatively try running on CPU, which should support int64 and so may avoid the error.

@saxenarohit
Copy link

Resizing the image worked for me with max_dimension =1024

def img_resize(image,max_dimension):
    width, height = image.size
    if width > max_dimension or height > max_dimension:
        if width > height:
            new_width = max_dimension
            new_height = int(height * (max_dimension / width))
        else:
            new_height = max_dimension
            new_width = int(width * (max_dimension / height))
        image = image.resize((new_width, new_height), Image.Resampling.LANCZOS)
    return image

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

No branches or pull requests

6 participants