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

Automatic mask generator onnx

Open maheshs11 opened this issue 2 years ago • 12 comments

How to convert Sam automatic mask generator (generate ) function to onnx to gain speed up?

maheshs11 avatar May 08 '23 14:05 maheshs11

#255

Mr-LiuDC avatar May 10 '23 03:05 Mr-LiuDC

Hi @maheshs11 did you find a way to segment the whole image withh onnx model please

assia855 avatar May 15 '23 10:05 assia855

@assia855 no

maheshs11 avatar May 15 '23 13:05 maheshs11

Any updates on this?

praveenporsche avatar May 23 '23 19:05 praveenporsche

I also have this problem.

JinghuiZhou avatar May 30 '23 16:05 JinghuiZhou

Did you find a solution? @maheshs11 @assia855 @praveenporsche @JinghuiZhou

WaterKnight1998 avatar Jul 27 '23 16:07 WaterKnight1998

Also looking for a solution for this

HowieG avatar Aug 04 '23 23:08 HowieG

Did you find a solution? @maheshs11 @assia855 @praveenporsche @JinghuiZhou

can not find a solution right now

JinghuiZhou avatar Aug 07 '23 05:08 JinghuiZhou

Any updates? @maheshs11 @assia855 @praveenporsche @JinghuiZhou

chandrasuda avatar Apr 07 '25 01:04 chandrasuda

+1

kipavy avatar Aug 27 '25 09:08 kipavy

+1

hilaryliang avatar Nov 07 '25 03:11 hilaryliang

For anyone still wanting to do this, the auto-mask procedure involves a lot of dynamic memory use, so it would be difficult/impossible to do entirely in onnx. Instead, it would be easier to use the SAM onnx model for generating mask predictions and then handle the auto-mask filtering logic outside of onnx (in python or C++ or whatever is executing the onnx model). The code that needs to be implemented is mostly inside the _process_batch function, which filters out masks based on various threshold settings, along with the final non-max suppression step which removes duplicate masks.

If you are trying to implement this, I have a slightly simplified version of the filtering logic and final NMS step, which might be easier to follow and includes a visualization (though it doesn't include the cropping logic from the original SAM implementation).

heyoeyo avatar Nov 14 '25 15:11 heyoeyo