zrporz / AutoSeg-SAM2

28 stars 1 forks source link

Works really slow #5

Open Gall-ardo opened 3 days ago

Gall-ardo commented 3 days ago

Hi, is it normal for the code to run very slowly when taking inference? It took about 75 minutes on an a100 gpu for a 128 frame video.

zrporz commented 2 days ago

Hi, thanks for your question. Currently there are three ways to improve efficiency:

  1. Increase detect_stride , the current default value is 10, which means that every 10 frames may need to re-segment the image to find the latest occurrence of the object. If objects don't appear that frequently in your dataset, you can increase this value appropriately.
  2. In the process of implementing the code, I saved the intermediate segmentation results in order to make it easier to observe the results, if you find that it's the process that causes the disk io to be too slow, you can try to remove these save operations.
  3. You can improve the efficiency of your code by tweaking SegmentAnything-2's parameters to improve efficiency https://github.com/facebookresearch/sam2/issues/105 gives a feasible operation, if your image resolution is relatively large, you can appropriately reduce the resolution of the mask to improve the efficiency of SAM2

You can try these methods to optimize code efficiency, and I look forward to talking with you further!

MustafaUtkuAydogdu commented 11 hours ago

Is it normal that it takes 75 minutes for a 128 frame single video on A100? What is the average time in your trials ( I am asking for any gpu-video pair not necessarily for a100 and 128 frames.)?

zrporz commented 8 hours ago

I think with the default configuration you're running roughly normal efficiency at the moment, the scenario we're using for testing has about four hundred fps and takes a couple of hours. As I mentioned above, reducing the saving of intermediate results and increasing detect_stride can significantly improve efficiency.