Updating to Sentis v2.0.0 - InvalidOperationException: Failed to add object of type `ModelAssetWeightsData`

Small PSA:

Upgrading from older Sentis versions throws some errors right now. Pretty reproducible for me.
First, after I upgrade a project to Sentis v2.0.0 from an older version, I get:

Restarting the project fixes the above issue, but all .onnx assets still show the following import error. (Happens for all models)

InvalidOperationException: Failed to add object of type `ModelAssetWeightsData`. Check that the definition is in a file of the same name and that it compiles properly.
UnityEditor.AssetImporters.AssetImportContext.AddObjectToAsset (System.String identifier, UnityEngine.Object obj) (at <97436df440ca462884c5332c1d8ebbe7>:0)
Unity.Sentis.ONNXModelImporter.OnImportAsset (UnityEditor.AssetImporters.AssetImportContext ctx) (at ./Library/PackageCache/com.unity.sentis@2.0.0/Editor/ONNX/ONNXModelImporter.cs:76)
UnityEditor.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.AssetImporters.AssetImportContext ctx) (at <97436df440ca462884c5332c1d8ebbe7>:0)

Asset import failed, "Assets/EasyOCR/1_recognition_model.onnx" > InvalidOperationException: Failed to add object of type `ModelAssetWeightsData`. Check that the definition is in a file of the same name and that it compiles properly.
UnityEditor.AssetImporters.AssetImportContext.AddObjectToAsset (System.String identifier, UnityEngine.Object obj) (at <97436df440ca462884c5332c1d8ebbe7>:0)
Unity.Sentis.ONNXModelImporter.OnImportAsset (UnityEditor.AssetImporters.AssetImportContext ctx) (at ./Library/PackageCache/com.unity.sentis@2.0.0/Editor/ONNX/ONNXModelImporter.cs:76)
UnityEditor.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.AssetImporters.AssetImportContext ctx) (at <97436df440ca462884c5332c1d8ebbe7>:0)

To fix it, I need to go to Project View, right-click ‘Assets’ → Reimport All
(equivalent to deleting the Library folder)

Ok thanks for the heads up. And good to know that re-importing it works.
I’ll look into it, I have some hunch as to what the issue is

1 Like

I was unable to reproduce this going from Sentis 1.6.0-pre.1 to Sentis 2.0.0 in Unity 2023.2.6f1 on MacOS.

Which version of Sentis are you upgrading from, and which version of the Unity Editor are you running in?

1 Like

From 1.6.0-pre.1 → 2.0.0

Ah yes, I’m still on 2022.3 because it’s the latest LTS.
Trying on 6000.0.14f1 also doesn’t have this issue for me.

I’d be fine with this not being fixed then, given that Sentis has been 2023+ for some versions now and since there’s a workaround. Unless there’s an easy fix or something.