Hi, I have some problem using MLagents.
- The onnx file was created through mlagents.
- and that file drag&drop to the agent(behavior param) , it works without any problem.
- I want to load and replace this onnx file at runtime(in script) , but the following message appears.
Is there any other way to solve this problem?
Thank you for read this…
[my code]
byte[] modelValues = File.ReadAllBytes(_modelPath);
Unity.Barracuda.NNModel nnmodel = ScriptableObject.CreateInstance<Unity.Barracuda.NNModel>();
nnmodel.modelData = ScriptableObject.CreateInstance<Unity.Barracuda.NNModelData>();
nnmodel.modelData.Value = modelValues;
nnmodel.name = "sa_agent";
rl_env.GetComponent<shooting_env>().AgentsList[0].Agent.GetComponent<BehaviorParameters>().Model = nnmodel;
[Message]
System.NotSupportedException: Format version not supported: 244
at Unity.Barracuda.ModelLoader+d__11.MoveNext () [0x00106] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.barracuda@2.4.0-preview\Barracuda\Runtime\Core\ModelLoader.cs:223
at Unity.Barracuda.ModelLoader.Load (System.IO.BinaryReader fileReader, System.Boolean verbose, System.Boolean applyPatching, System.Boolean skipWeights) [0x0002d] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.barracuda@2.4.0-preview\Barracuda\Runtime\Core\ModelLoader.cs:200
at Unity.Barracuda.ModelLoader.Load (System.Byte[ ] stream, System.Boolean verbose, System.Boolean skipWeights) [0x00001] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.barracuda@2.4.0-preview\Barracuda\Runtime\Core\ModelLoader.cs:140
at Unity.Barracuda.ModelLoader.Load (Unity.Barracuda.NNModel model, System.Boolean verbose, System.Boolean skipWeights) [0x00001] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.barracuda@2.4.0-preview\Barracuda\Runtime\Core\ModelLoader.cs:31
at Unity.MLAgents.Inference.ModelRunner…ctor (Unity.Barracuda.NNModel model, Unity.MLAgents.Actuators.ActionSpec actionSpec, Unity.MLAgents.Policies.InferenceDevice inferenceDevice, System.Int32 seed) [0x00085] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.ml-agents@2.1.0-exp.1\Runtime\Inference\ModelRunner.cs:72
at Unity.MLAgents.Academy.GetOrCreateModelRunner (Unity.Barracuda.NNModel model, Unity.MLAgents.Actuators.ActionSpec actionSpec, Unity.MLAgents.Policies.InferenceDevice inferenceDevice) [0x00036] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.ml-agents@2.1.0-exp.1\Runtime\Academy.cs:620
at Unity.MLAgents.Policies.BarracudaPolicy…ctor (Unity.MLAgents.Actuators.ActionSpec actionSpec, System.Collections.Generic.IList`1[T] actuators, Unity.Barracuda.NNModel model, Unity.MLAgents.Policies.InferenceDevice inferenceDevice, System.String behaviorName) [0x00008] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.ml-agents@2.1.0-exp.1\Runtime\Policies\BarracudaPolicy.cs:84
at Unity.MLAgents.Policies.BehaviorParameters.GeneratePolicy (Unity.MLAgents.Actuators.ActionSpec actionSpec, Unity.MLAgents.Actuators.ActuatorManager actuatorManager) [0x000b9] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.ml-agents@2.1.0-exp.1\Runtime\Policies\BehaviorParameters.cs:240
at Unity.MLAgents.Agent.ReloadPolicy () [0x00023] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.ml-agents@2.1.0-exp.1\Runtime\Agent.cs:648
at Unity.MLAgents.Policies.BehaviorParameters.UpdateAgentPolicy () [0x00016] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.ml-agents@2.1.0-exp.1\Runtime\Policies\BehaviorParameters.cs:276
at Unity.MLAgents.Policies.BehaviorParameters.set_Model (Unity.Barracuda.NNModel value) [0x00008] in D:\project_junhyeoklee\GA_map_evolution\Library\PackageCache\com.unity.ml-agents@2.1.0-exp.1\Runtime\Policies\BehaviorParameters.cs:108
at mapEvolvWithRL_SceneManager_controller.Initialized (System.String _loadMapFilePath, System.String _modelPath) [0x001af] in D:\project_junhyeoklee\GA_map_evolution\Assets\Scripts\SA\mapEvolvWithRL_SceneManager_controller.cs:337
UnityEngine.Debug:Log (object)
mapEvolvWithRL_SceneManager_controller:Initialized (string,string) (at Assets/Scripts/SA/mapEvolvWithRL_SceneManager_controller.cs:342)
mapEvolvWithRL_SceneManager_controller:Start () (at Assets/Scripts/SA/mapEvolvWithRL_SceneManager_controller.cs:194)