> 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

Quick Primer

## 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.](https://687653739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MId3QBjkfWUbuw5p8kV%2Fuploads%2FE9bCdnypHdfLhWsjOikV%2Fkey.png?alt=media\&token=70e23715-ca60-4647-94d7-f4e7d19a3b32)

## Importing a Sample Image

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

![A Cat](https://687653739-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MId3QBjkfWUbuw5p8kV%2F-M_wAC23XeLI13XRArLj%2F-M_wBqCaZyNLdxkXNO9m%2Fcat.jpg?alt=media\&token=210b3435-434c-4a46-82b4-fda4171c3ac7)

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

![Import the cat image.](https://687653739-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MId3QBjkfWUbuw5p8kV%2F-M_wAC23XeLI13XRArLj%2F-M_wF7dQnBwN8TlquPkY%2FScreen%20Shot%202021-05-17%20at%2017.34.19.png?alt=media\&token=c7f509a6-e2d3-4e1a-8ef5-fe116e5bb309)

## 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.](https://687653739-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MId3QBjkfWUbuw5p8kV%2F-M_wAC23XeLI13XRArLj%2F-M_wIyQW1XL035fbGIiu%2FScreen%20Shot%202021-05-17%20at%2017.51.04.png?alt=media\&token=5c2b7dbf-7a2a-40c5-b86c-9405a9f8a4f9)

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

![It's a cat!](https://687653739-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MId3QBjkfWUbuw5p8kV%2F-M_wJEjqJJeQyHq3pijL%2F-M_wJWNCABejG8qOSMGV%2FScreen%20Shot%202021-05-17%20at%2017.53.34.png?alt=media\&token=88b94bb4-9410-4d6d-a5b8-bc3ad1251b1b)
