microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.25k stars 2.87k forks source link

example on loading an ONNX File as embeded Resource on C#. #5587

Open Yandychang1 opened 3 years ago

Yandychang1 commented 3 years ago

I am looking for an example on loading an ONNX file from an embedded resource in c#, and was wondering if anyone could point me in the right direction.

yuslepukhin commented 3 years ago

Providing you know how to access your resource, which is built-in into your application, such a resource would contain a binary blob that holds a serialized ONNX model. You then need to instantiate InferenceSession object using one of the two constructors that take byte[] as an argument. See https://github.com/microsoft/onnxruntime/blob/master/csharp/src/Microsoft.ML.OnnxRuntime/InferenceSession.cs#L54 and https://github.com/microsoft/onnxruntime/blob/master/csharp/src/Microsoft.ML.OnnxRuntime/InferenceSession.cs#L65

Yandychang1 commented 3 years ago

Thank you very much, It worked nicely...