IDEA-Research / Grounded-Segment-Anything

Grounded SAM: Marrying Grounding DINO with Segment Anything & Stable Diffusion & Recognize Anything - Automatically Detect , Segment and Generate Anything
https://arxiv.org/abs/2401.14159
Apache License 2.0
14.23k stars 1.31k forks source link

Grounding-SAM Issues with multi-image predictions #448

Open erictan23 opened 5 months ago

erictan23 commented 5 months ago

Hello! Thank you for your work, I would like to ask some questions regarding multiple images predicting using the grounded_sam_demo. I have looked through previous issues, there seem to be some way to perform multi-batch inference? I am not very sure how it works, but I tried to create a for loop in my image_paths to predict all the .jpg in my image files. However, when I am on my 2nd loop, cuda ran out of memory, hence would like to see if anyone has any solution to this?

This was what I have adjusted mainly in grounded_sam_demo.py image

This shows that cuda ran out of memory... image

dario-loi commented 4 months ago

Not a maintainer, however it looks like the reason for the error is that you simply do not have enough VRAM on your system to perform inference on a batch of that size, try to reduce the batch size until you get to a load that your GPU is comfortable with.

slayerfrank commented 1 month ago

same problem. 12G VRAM. Loop 2 times will run out of mem.

BeCarefulOfYournaoke commented 1 month ago

use 'plt.close('all')' maybe ok