Skip to content

This repository shows how to solve ONNX export issue in Segment Anything model

License

Notifications You must be signed in to change notification settings

AndreyGermanov/sam_onnx_full_export

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Segment Anything full ONNX export

This is a source code for the Export Segment Anything neural network to ONNX: the missing parts article.

Both the article and this repository aimed to show how to solve the ONNX export issue in the Segment Anything model. Official documentation explains how to export only the mask decoder model, but not the image encoder. So, even with exported ONNX model, developer still needs to use original PyTorch model and official API. It makes most benefits of ONNX useless and greatly limits the possible use of this model in production. Due to this, the Segment Anything network can be deployed only with Python and only if PyTorch and official API installed.

This repo fills this gap, here you can find how to export both SAM image encoder and mask decoder and how to use them for inference with only ONNX.

  • sam_onnx_export.ipynb - Shows how to export both image encoder and masks decoder models to ONNX.
  • sam_onnx_inference.ipynb - Shows how to use exported models for image segmentation.

Read the article for thorough explanation of this code.

About

This repository shows how to solve ONNX export issue in Segment Anything model

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published