natmlx / natml-unity

High performance, cross-platform machine learning for Unity Engine.
Apache License 2.0
228 stars 25 forks source link
android augmented-reality computer-vision coreml deeo-learning ios machine-learning macos mediapipe natml natural-language-processing pytorch tensorflow tensorflow-lite unity virtual-reality webassembly webassemby webgl windows

NatML

NatML

[!CAUTION] NatML has officially been deprecated. We have created a new platform for running AI models on-device called Function.

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:

Installing NatML

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

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

Using ML Models

drag and drop

If you have a CoreML, ONNX, or TensorFlow Lite model, you can simply drag and drop it into your project. See the documentation for more details.

Note that specific model formats can only be used on specific platforms. CoreML models can only be used on iOS and macOS; ONNX can only be used on Windows; and TensorFlow Lite can only be used on Android. Use NatML Hub to convert your model to different ML formats.

Discover ML Models on NatML 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 documentation for information on writing predictors for your models.

Using ML Models in Two Simple Steps

You will always use NatML in two steps. First, create a predictor by fetching model data from NatML Hub or by loading a local ML model file in your project (.mlmodel, .tflite, and .onnx):

// Create the MobileNet v2 predictor
var predictor = await MobileNetv2Predictor.Create();

Then make predictions with the predictor:

// Make prediction on an image
Texture2D image = ...;
var (label, score) = predictor.Predict(image);

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


Requirements

Supported Platforms

Resources

Thank you very much!