Can I integrate python into unity mlagents?

I am coming from pytorch background in case of machine learning. I would like to make simple project and create whole environment in Unity. The thing is I would like to utilize python if it’s possible. So, is it possible to use python/pytorch with mlagents. If yes, then how can I make it work together?

Hi. You can definitely interact with your environment using python and models running in PyTorch. See here for the guide to using our Python API: https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Python-API.md

I’ve been using MLAgents 0.15.1 and have hard a very difficult time getting my Python Pytorch model to work with my project. One of the main issues was getting the model file to re-run back onto Unity. I had to format the model to be a barracuda model and use using barracuda to get anything to load (could not plug my model back into mlagents).
I’m continuing to deal with many issues.

Is the latest version of MLAgents any different? Was something changed? Is there an example showing how to train agents with Pytorch then plug the model back into unity?

Hey there @janimator - which version of Python are you using?

Hey @janimator , this is currently not supported by ML-Agents. You may try exporting as ONNX format and importing it to Unity, but no guarantees on if it will work. See the Barracuda documentation for more information: Introduction to Barracuda | Barracuda | 1.0.4

Hi, I am trying something similar. I trained a model in PyTorch and I want to use it as a back-end. I want to be able to run the ML and the environment in Python and communicate back and forth with unity to support user-interaction.

What is the best way to enable this type of communication? Is mlagents or a custom socket communication between Python and C# more appropriate?