Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to create onnx??

Discussion in 'ML-Agents' started by Airmouse, Aug 27, 2022.

  1. Airmouse

    Airmouse

    Joined:
    Jan 12, 2019
    Posts:
    107
    Hi, I have now been trying for over 5 days to install Tensorflow 2.9, Keras, Pytorch and tf2onnx. but am completely unable to crete a working onnx for Unity,

    I created a simple model in Keras then used tf2onnx to create a onnx model.

    I then added it to the Unity project and created a new Agent controller,

    placed the onnx in the model field and it always says required constant VERSION_NUMBER missing.

    ---

    if I bypass version number requirement:
    Code (CSharp):
    1. public static int GetVersion(this Model model)
    2. {
    3.     return 2;//(int)model.GetTensorByName(TensorNames.VersionNumber)[0];
    4. }
    then I get new error:
    UnityAgentsException: Models from com.unity.ml-agents 1.x that use recurrent neural networks are not supported in newer versions. Either retrain with an newer trainer, or use an older version of com.unity.ml-agents.


    I am trying to learn what is the simplest way to create a onnx that works in Unity and am so far unsuccessful at ever attept. I have no idea what to do now. There are no tutorials I can find anywhere and documentation seems to be from many years ago.

    can someone please help me to create a working onnx that Unity can understand?

    Here is the onnx model file: https://www.mediafire.com/file/dxo17zpcewdr1o3/catsvsdogs.onnx
    Here is the Python code: https://www.mediafire.com/file/vtn6j40n1suy9bv/keras_cats_vs_dogs.py

    Is Keras even supported?? Or do I have to use torch??
     
    Last edited: Aug 27, 2022