Wiki › Project
ONNX models in Unity
Article
ReadAll pages
From Chaipat's knowledge graph
ONNX models in Unity is a step-by-step guide, with a working Unity project, for running a deep-learning model trained in Keras inside a Unity game. It was tested on macOS with Unity 2023.2 and Python 3.11.
Steps
- Save the trained Keras model and export it in TensorFlow's SavedModel format.
- Convert it to ONNX, the open model-exchange format, with
tf2onnx. - Import the
.onnxfile into Unity and run it from C# with Unity's Barracuda inference library.
The README pins the exact library versions that worked (TensorFlow 2.16.1, Keras 3.3.3 and tf2onnx 1.16.1), because conversion is sensitive to versions.