asus4 / onnxruntime-unity

ONNX Runtime Plugin for Unity
53 stars 2 forks source link

Onnx importing should be allowed with Sentis installed. #32

Closed SetoKaiba closed 2 days ago

SetoKaiba commented 3 days ago

Environment (please complete the following information):

Describe the bug Onnx importing should be allowed with Sentis installed. Due to #26 , onnx is not allowed imported. But platform we may prefer onnxruntime. For example for low end Android XR glasses, Sentis doesn't allow the model totally run in background thread. Only nn is run by job in background thread. In such case, onnxruntime is preferred.

To Reproduce Not related

Expected behavior Onnx importing should be allowed with Sentis installed.

Screenshots Not related

Additional context Not related

asus4 commented 2 days ago

Hi @SetoKaiba, It's not possible, afaik.

The ScriptedImporter throws an error like the one below when there is a conflict with the extension.

Multiple scripted importers are targeting the extension 'onnx' and have all been rejected: Unity.Sentis.ONNXModelImporter (assembly: /onnxruntime-unity-examples/Library/ScriptAssemblies/Unity.Sentis.ONNX.dll), Microsoft.ML.OnnxRuntime.Unity.Editor.OrtImporter (assembly: /onnxruntime-unity-examples/Library/ScriptAssemblies/com.github.asus4.onnxruntime.unity.Editor.dll) 
UnityEditor.AssetImporters.ScriptedImporter:RegisterScriptedImporters () (at /Users/bokken/build/output/unity/unity/Modules/AssetPipelineEditor/Public/ScriptedImporter.cs:112)

Here's some workaround to read onnx with Sentis:

  1. Place the onnx file in the StreamingAssets folder. The files in the StreadmingAssets are not imported by ScriptedImporter.
  2. Rename the extension from onnx to bytes. The model is imported as raw binary data. And OnnxRuntime.InferenceSession can load it.
SetoKaiba commented 2 days ago

https://discussions.unity.com/t/multiple-glb-importers-how-do-i-fix-this/900888

What about make it an optional scripted importer?

asus4 commented 2 days ago

Thanks @SetoKaiba.

I didn't know it. It worked with Sentis.

optional-importer