api.natsuite.natml

High performance, cross platform machine learning runtime for Unity Engine.

Usage no npm install needed!

<script type="module">
  import apiNatsuiteNatml from 'https://cdn.skypack.dev/api.natsuite.natml';
</script>

README

NatML

NatML

NatML allows developers to integrate machine learning into their Unity applications in under five lines of code with zero infrastructure. NatML completely removes the need to have any experience with machine learning in order to take advantage of the features it can provide. Features include:

  • Bare Metal Performance. NatML takes advantage of hardware machine learning accelerators, like CoreML on iOS and macOS, NNAPI on Android, and DirectML on Windows. As a result, it is multiple times faster than Unity's own Barracuda engine.

  • Extremely Easy to Use. NatML exposes machine learning models with simple classes that return familiar data types. These are called "Predictors", and they handle all of the heavy lifting for you. No need to write pre-processing scripts or shaders, wrangle tensors, or anything of that sort.

  • Cross Platform. NatML supports Android, iOS, macOS, and Windows alike. As a result, you can build your app once, test it in the Editor, and deploy it to the device all in one seamless workflow.

  • Growing Ecosystem. NatML is designed with a singular focus on applications. As a result, there is a growing ecosystem of predictor packages for ML models and applications that run on NatML. Check out NatML Hub.

  • Augmented Reality. NatML is particularly suited for augmented reality because it delegates work to ML accelerators, freeing up the GPU to render your app smoothly.

  • Lightweight Package. NatML is distributed in a self-contained package, with no external dependencies. As a result, you can simply import the package and get going--no setup necessary.

Installing NatML

Add the following items to your Unity project's Packages/manifest.json:

{
  "scopedRegistries": [
    {
      "name": "NatML",
      "url": "https://registry.npmjs.com",
      "scopes": ["api.natsuite"]
    }
  ],
  "dependencies": {
    "api.natsuite.natml": "1.0.8"
  }
}

Discover ML Models on Hub

Create an account on NatML Hub to find and download ML predictors to use in your project!

NatML Hub

You can also upload your models to Hub and make them private or public. Check out the online documentation for information on authoring predictors.

Using ML Models in Three Simple Steps

You will always use NatML in three steps. First, create a model from model data:

// Fetch model data from NatML Hub
var accessKey = "<HUB ACCESS KEY>"; // Get your access key from https://hub.natml.ai/profile
var modelData = await MLModelData.FromHub("@author/some-model", accessKey);
// Deserialize the model
var model = modelData.Deserialize();

Then create a predictor to make predictions with the model:

// Create a predictor for the model
var predictor = new SomePredictor(model);

Finally, make predictions with the predictor:

// Make prediction on an image
Texture2D input = ...;
var someOutput = predictor.Predict(input);

Different predictors accept and produce different data types, but the usage pattern will always be the same.


Requirements

  • Unity 2019.2+

Supported Platforms

  • Android API Level 24+
  • iOS 13+
  • macOS 10.15+ (Intel only)
  • Windows 10+, 64-bit only

Resources

Thank you very much!