> For the complete documentation index, see [llms.txt](https://docs.natml.ai/unity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.natml.ai/unity/prelims/getting-started.md).

# Getting Started

## Importing NatML

To begin, [import NatML to your Unity project](https://github.com/natmlx/NatML#installing-natml) by adding the following lines to your Unity project's `Packages > manifest.json` file:

<pre class="language-json"><code class="lang-json">{
<strong>  "scopedRegistries": [
</strong><strong>   {
</strong><strong>    "name": "NatML",
</strong><strong>    "url": "https://registry.npmjs.com",
</strong><strong>    "scopes": ["ai.natml"]
</strong><strong>   }
</strong><strong>  ],
</strong>  "dependencies": {
<strong>    "ai.natml.natml": "1.1.8",
</strong>    ...
  }
}
</code></pre>

Once NatML has been imported, you can run ML models right in the Editor. For this example, we will classify an image using the popular [MobileNet classifier](https://hub.natsuite.io/predictor/@natsuite/mobilenet-v2) architecture:

{% embed url="<https://hub.natml.ai/@natsuite/mobilenet-v2>" %}
Get the MobileNet v2 predictor from NatML Hub.
{% endembed %}

## Importing the MobileNet Predictor

First, we'll import the MobileNet predictor into our project by following [the import instructions](https://github.com/natml-hub/MobileNet-v2/tree/main/Packages/ai.natml.vision.mobilenet-v2):

<pre class="language-json" data-title="Packages/manifest.json" data-line-numbers><code class="lang-json">{
  ...,
  "dependencies": {
    "ai.natml.natml": "1.1.8",
<strong>    "ai.natml.vision.mobilenet-v2": "1.0.3",
</strong>    ...
  }
}
</code></pre>

{% hint style="info" %}
The recommended way to make predictions with ML models is using [Predictors](/unity/workflows/concepts.md#predictors). These are lightweight classes that 'know how' to format the model's input and output features.
{% endhint %}

## Specifying your NatML Access Key

We will fetch our models from [NatML Hub](https://hub.natml.ai/profile), . To do so, we need to retrieve our access key:

{% embed url="<https://hub.natml.ai/profile>" %}
Get your access key from NatML Hub
{% endembed %}

Once you have an access key, you can add it to your Unity project in `Project Settings > NatML`:

![Specifying your access key in a Unity project.](/files/3oLYa7g8uYsCrl7KeiwK)

## Importing a Sample Image

Next, import the image below (download it into your Unity project):

![A Cat](/files/-M_wBqCaZyNLdxkXNO9m)

Make sure that in the advanced settings, you enable the `Read/Write Enabled` setting:

![Import the cat image.](/files/-M_wF7dQnBwN8TlquPkY)

## Making a Prediction

Now, we can write a small script to classify the image:

{% code title="Classifier.cs" %}

```csharp
using UnityEngine;
using NatML.Vision;

public class Classifier : MonoBehaviour {
    
    [Header(@"Prediction")]
    public Texture2D image;
    
    async void Start () {
        // Create the MobileNet predictor
        using var predictor = await MobileNetv2Predictor.Create();
        // Classify the image feature
        var (label, confidence) = predictor.Predict(image);
        // Log the result
        Debug.Log($"Image contains {label} with confidence {confidence}");     
    }
}
```

{% endcode %}

Now, let us add our script to the scene and assign the inspector variables:

![Create an empty object and add the Classifier script we just created.](/files/-M_wIyQW1XL035fbGIiu)

Now, we run the script to confirm that our model predicted the image correctly!

![It's a cat!](/files/-M_wJWNCABejG8qOSMGV)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.natml.ai/unity/prelims/getting-started.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
