docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Import a model file

    To import an ONNX model file into your Unity project, drag the .onnx file from your computer into the Assets folder of the Project window.

    If your model has external weights files, put them in the same directory as the model file so that Inference Engine imports them automatically.

    For more information on supported model formats, refer to Supported models.

    Create a runtime model

    To use an imported model in your scene, use ModelLoader.Load to create a runtime Model object.

    using UnityEngine;
    using Unity.InferenceEngine;
    
    public class CreateRuntimeModel : MonoBehaviour
    {
        public ModelAsset modelAsset;
        Model runtimeModel;
    
        void Start()
        {
            runtimeModel = ModelLoader.Load(modelAsset);
        }
    }
    

    After the model is loaded, you can create an engine to run a model.

    Additional resources

    • How Inference Engine optimizes a model
    • Export an ONNX file from a machine learning framework
    • Model Asset Inspector
    • Supported models
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)