MLAgents Version: 0.15.1
I’ve begun to dive into the unknown territory of trying to get a PyTorch model into an MLAgent within Unity. Looking at whatever forum threads I can find it seems that converting the model into a Barracuda model might do the trick. I was successful in converting PyTorch > Onnx > Barracuda and in the inspector, the model looks like this
but I am not able to drag the model(“brain”) into the MLAgent via inspector. If I try to drag the model into the inspector I see the following error log.
NullReferenceException: Object reference not set to an instance of an object
MLAgents.Inference.BarracudaModelParamLoader.CheckModel (Barracuda.Model model, MLAgents.Policies.BrainParameters brainParameters, MLAgents.Sensors.SensorComponent[] sensorComponents, MLAgents.Policies.BehaviorType behaviorType) (at C:/Users/Janimator0/Desktop/UnityMLAgent_Project/ml-agents/com.unity.ml-agents/Runtime/Inference/BarracudaModelParamLoader.cs:149)
MLAgents.Editor.BehaviorParametersEditor.DisplayFailedModelChecks () (at C:/Users/Janimator0/Desktop/UnityMLAgent_Project/ml-agents/com.unity.ml-agents/Editor/BehaviorParametersEditor.cs:108)
MLAgents.Editor.BehaviorParametersEditor.OnInspectorGUI () (at C:/Users/Janimator0/Desktop/UnityMLAgent_Project/ml-agents/com.unity.ml-agents/Editor/BehaviorParametersEditor.cs:68)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass55_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <887a438259064e89922419bc7b8810ab>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
I’ve read on another forum something about naming the consts correctly might do the trick but I’m unsure what the steps are for that? Can't load external model to agent (from .pth convert to .onnx and then to .nn) · Issue #3398 · Unity-Technologies/ml-agents · GitHub ← mentioned in this thread.
My questions are is it at all possible to get my PyTorch model to work on an MLAgent? Is it even possible to get a TensorFlow model to work on a MLAgent? What can be done to achieve this? How can I ensure that the “consts” are named correctly?