Quantcast
Channel: AI Beta - Unity Discussions
Viewing all articles
Browse latest Browse all 109

Load onnx model from bytes

$
0
0

Hello,

I’m training the model using Ml Agents on a remote server, and than send it to unity, and when i try to create the ModelAsset i had the following error:

NotSupportedException: Format version not supported: 118621192, please reimport model.
Unity.Sentis.ModelLoader.LoadModelDesc (System.IO.Stream stream, Unity.Sentis.Model& model) (at ./Library/PackageCache/com.unity.sentis@1.2.0-exp.2/Runtime/Core/ModelLoader.cs:96)

But if i save it to the disk and than manualy added to unity it works.

the code i’m using to create the ModelAsset is the following:
public static ModelAsset LoadModelRuntime(byte rawModel, string behaviourName)
{
var asset = ScriptableObject.CreateInstance();
asset.modelAssetData = ScriptableObject.CreateInstance();
asset.modelAssetData.value = rawModel;
asset.name = behaviourName;
return asset;
}

Info about the model.
image

To set the model, where i have the error i’m using the function SetModel() from the Agent
public void SetModel(
string behaviorName,
ModelAsset model,
InferenceDevice inferenceDevice = InferenceDevice.Default)
{
if (behaviorName == m_PolicyFactory.BehaviorName &&
model == m_PolicyFactory.Model &&
inferenceDevice == m_PolicyFactory.InferenceDevice)
{
// If everything is the same, don’t make any changes.
return;
}
NotifyAgentDone(DoneReason.Disabled);
m_PolicyFactory.Model = model;
m_PolicyFactory.InferenceDevice = inferenceDevice;
m_PolicyFactory.BehaviorName = behaviorName;
ReloadPolicy();
}

Thanks

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 109

Trending Articles