segment-anything icon indicating copy to clipboard operation
segment-anything copied to clipboard

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

Open harry-esmart opened this issue 1 year ago • 6 comments

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

harry-esmart avatar Jun 09 '23 13:06 harry-esmart

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.

MikeLilley avatar Jun 09 '23 13:06 MikeLilley

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

theFilipko avatar Sep 13 '23 08:09 theFilipko

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).

theFilipko avatar Sep 13 '23 11:09 theFilipko

I have the same problem, still no response

sdlyzhq avatar Jan 08 '24 16:01 sdlyzhq

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.

heyoeyo avatar Jan 08 '24 17:01 heyoeyo