English | 简体中文
[Paper
] [Source Code
]
Based on C# language, ONNX format Segment Anything reasoning program. Although the official pre-training model and inference code are provided, the pre-training model is only in pytorch format, and the inference code only provides Python code based on the Pytorch framework. This project consists of two parts:
- Split the officially released pre-training model into encoder and decoder, and save them in ONNX format.
- Use C# language to load the model, perform inference, and use WPF for interaction and display.
- Download the source code to the local
2.Visual Studio opens the .sln project solution - Install the Nuget package
3.1 In Visual Studio, right-click on the project and select "Manage NuGet Packages".
3.2 In the "NuGet Package Manager" window, select the "Browse" tab.
3.3 Search for Microsoft.ML.OnnxRuntime, select version 1.15.1, and click Install
3.4 Search for OpenCvSharp4, select version 4.8.0, and click Install
3.5 Search for OpenCvSharp4.runtime.win, select version 4.8.0, and click Install
3.6 the target platform of SAMViewer set x64 - Put decoder-quant.onnx , encoder-quant.onnx ,visual.onnx and textual.onnx in the exe path
- Run the program
Effect demo:
model file is upload to release, or pay attention to the following WeChat public account, and the background will reply [SAM]get model file download link
Pay attention to the WeChat public account: 人工智能大讲堂