tensorflow-onnx
tensorflow-onnx copied to clipboard
Onnx model import failed using Unity Barracuda
Onnx model import failed using Unity Barracuda
Problem
As mentioned here, the SSD mobile net support only since opset 10. However, here, Unity says to use opset 9 for wider coverage. Due to this, i cannot load my custom trained SSD object detection model in Unity. I get the following error.
Asset import failed, "Assets/Scenes/youngdusan_AR_model.onnx" > OnnxImportException: Unknown type Loop encountered while parsing layer StatefulPartitionedCall/map/while_loop:0.
Unity.Barracuda.ONNX.ONNXModelConverter.Err (Unity.Barracuda.Model model, System.String layerName, System.String message, System.String extendedMessage, System.String debugMessage) (at Library/PackageCache/[email protected]/Barracuda/Runtime/ONNX/ONNXModelConverter.cs:3434)
Unity.Barracuda.ONNX.ONNXModelConverter.ConvertOnnxModel (Onnx.ModelProto onnxModel) (at Library/PackageCache/[email protected]/Barracuda/Runtime/ONNX/ONNXModelConverter.cs:2954)
Unity.Barracuda.ONNX.ONNXModelConverter.Convert (Google.Protobuf.CodedInputStream inputStream) (at Library/PackageCache/[email protected]/Barracuda/Runtime/ONNX/ONNXModelConverter.cs:170)
Unity.Barracuda.ONNX.ONNXModelConverter.Convert (System.String filePath) (at Library/PackageCache/[email protected]/Barracuda/Runtime/ONNX/ONNXModelConverter.cs:98)
Unity.Barracuda.ONNXModelImporter.OnImportAsset (UnityEditor.AssetImporters.AssetImportContext ctx) (at Library/PackageCache/[email protected]/Barracuda/Editor/ONNXModelImporter.cs:65)
UnityEditor.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.AssetImporters.AssetImportContext ctx) (at <44a70d1b13cf47e29810e30f45ffae08>:0)
UnityEditorInternal.InternalEditorUtility:ProjectWindowDrag(HierarchyProperty, Boolean)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Any way to solve this issue?
Further information
The saved_model.pb was converted to onnx format using:
python -m tf2onnx.convert --saved-model {saved_model_directory} --{output_path/model_name.onnx}
Specifications:
tf2onnx==1.11.1
onnxruntime==1.11.1
tensorflow==2.8.0
Notes
Please feel free to set opset version to 10 or higher version when you are trying to convert a tf model to onnx model.
tf2onnx supports downward compatibility so if something is supported by 9, then it will also be supported in later versions. It is possible that the document of Unity is describing the lowest version needed.
@lakpa-tamang9 please did you solve this