docs.unity3d.com
Search Results for

    Show / Hide Table of Contents
    Note

    Sentis is now called Inference Engine. The documentation has moved to https://docs.unity3d.com/Packages/com.unity.ai.inference@latest. Refer to the new location for the latest updates and guidance. Make sure to update your bookmarks and references accordingly.

    Inspect a model

    You can inspect a runtime model in Unity to access its inputs, outputs, and layers. This helps you understand the model’s structure and integrate it into your application.

    Get model inputs

    Use the inputs property of the runtime model to get the inputs of the model with and the name and shape of each input.

    For example:

    using UnityEngine;
    using System.Collections.Generic;
    using Unity.Sentis;
    
    public class GetModelInputs : MonoBehaviour
    {
        public ModelAsset modelAsset;
    
        void Start()
        {
            Model runtimeModel = ModelLoader.Load(modelAsset);
    
            List<Model.Input> inputs = runtimeModel.inputs;
    
            // Loop through each input
            foreach (var input in inputs)
            {
                // Log the name of the input, for example Input3
                Debug.Log(input.name);
    
                // Log the tensor shape of the input, for example (1, 1, 28, 28)
                Debug.Log(input.shape);
            }
        }
    }
    

    Input dimensions can be fixed or dynamic. Refer to Model inputs for more information.

    Get model outputs

    Use the outputs property of the runtime model to get the names of the output layers of the model.

    For example:

    List<Model.Output> outputs = runtimeModel.outputs;
    
    // Loop through each output
    foreach (var output in outputs)
    {
        // Log the name of the output
        Debug.Log(output.name);
    }
    

    Get layers and layer properties

    Use the layers property of the runtime model to get the neural network layers in the model, and the index, inputs or outputs of each layer.

    Open a model as a graph

    To open an ONNX model as a graph, follow these steps:

    1. Install Netron, a third-party viewer for neural networks.
    2. Double-click a model asset in the Project window, or select the model asset then select Open in the Model Asset Import Settings window.

    Additional resources

    • Profile a model
    • Tensor fundamentals
    • Supported ONNX operators
    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)