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

torchScript Export

Open paul-ml75 opened this issue 2 years ago • 3 comments

Hi!

I truly appreciate the OXXN export script, which is fantastic. Would it be possible to add a TorchScript export as well? This addition would be extremely helpful for utilizing Segment-Anything with various third-party software.

Thank you,

Paul

paul-ml75 avatar Apr 18 '23 09:04 paul-ml75

Hi Paul, I've played a bit around with this and you can find a starting point here: https://github.com/csia-pme/djl-image-sam

leonardcser avatar Apr 21 '23 12:04 leonardcser

Hi Leonardscer!

that is absolutely awesome! having a look right now!

Paul

paul-ml75 avatar Apr 21 '23 17:04 paul-ml75

Hi leonardcser, Thanks for the helpful starting points! I was able to work with it.

One issue I see is that by wrapping the model it is cumbersome to use as part of the automatic_mask_generator provided by the facebook team. This script is very useful as it does a lot of heavy lifting of implementing moving windows (crops) and then deduping masks.

So I changed the sam_predictor to only script out image encoder, prompt encoder and mask decoder separately. With that we can continue to use the automatic_mask_generator as is. Just fyi.

darshats avatar Apr 24 '23 08:04 darshats