Unity
  • NatML for Unity
  • Preliminaries
    • Getting Started
    • Requirements
  • Workflows
    • Core Concepts
    • Fetching Models
    • Using Predictors
  • Authoring
    • Creating Predictors
    • Distributing Predictors
  • API Reference
    • IMLPredictor
    • MLModel
      • MLEdgeModel
        • Configuration
      • MLCloudModel
    • MLFeature
      • MLArrayFeature
      • MLImageFeature
      • MLStringFeature
      • MLAudioFeature
      • MLVideoFeature
      • MLDepthFeature
      • MLXRCpuDepthFeature
    • MLFeatureType
      • MLArrayType
      • MLAudioType
      • MLImageType
      • MLVideoType
      • MLStringType
    • MLPredictorExtensions
  • Integrations
    • Media Devices
    • Augmented Reality
    • Video Recording
  • Insiders
    • Changelog
    • Open Source
    • GitHub
    • Discord
    • Blog
Powered by GitBook
On this page
  • Creating a Feature
  • From an Array
  • From a Texture2D
  • From a WebCamTexture
  • From an AudioClip
  • From a String
  • Inspecting the Feature

Was this helpful?

  1. API Reference

MLFeature

abstract class NatML.MLFeature

PreviousMLCloudModelNextMLArrayFeature

Last updated 2 years ago

Was this helpful?

The MLFeature class is an abstract base class representing input and output features used in making predictions. All predictors accept one or more features, which are then provided to the model to make predictions.

Creating a Feature

NatML provides implicit conversions from common data types into MLFeature instances:

From an Array

// With a `float` array
float[] array = ...;
// Create a feature
MLFeature feature = array;
// Then make a prediction
predictor.Predict(feature);
// This works too
predictor.Predict(array);

NatML provides an implicit conversion from a float[] to an .

When this conversion is used, the created feature will have no shape information.

From a Texture2D

// With a `Texture2D`
Texture2D texture = ...;
// Create a feature
MLFeature feature = texture;
// Then make a prediction
predictor.Predict(feature);
// This works too
predictor.Predict(texture);

From a WebCamTexture

// With a `WebCamTexture`
WebCamTexture webCamTexture = ...;
// Create a feature
MLFeature feature = webCamTexture;

From an AudioClip

// With an `AudioClip`
AudioClip audioClip = ...;
// Create a feature
MLFeature feature = audioClip;

From a String

// With a `string`
var text = "hello, world";
// Create a feature
MLFeature feature = text;

Inspecting the Feature

/// <summary>
/// Feature type.
/// </summary>
MLFeatureType type { get; }

The feature type is immutable and can never be null.

NatML provides an implicit conversion from a to an .

The class will handle any conversions of pixel data to match a model's required .

NatML provides an implicit conversion from a to an .

NatML provides an implicit conversion from an to an .

NatML provides an implicit conversion from a string to an .

Every feature has a corresponding that provides information about the feature's shape, data type, and so on.

MLArrayFeature
Texture2D
MLImageFeature
WebCamTexture
MLImageFeature
AudioClip
MLAudioFeature
MLTextFeature
MLFeatureType
MLImageFeature
input type