Preparing search index...

    Class MLComponent

    Used to integrate machine learning models into a Lens.

    This component allows developers to use neural networks for processing inputs such as textures or data arrays to produce specific outputs, which could be in the form of processed textures or data alterations. The MLComponent relies on MLAsset that defines the neural network model used. It supports tasks like image classification, object detection, etc.

    //@input Asset.MLAsset model
    var mlComponent = script.sceneObject.createComponent('MLComponent');
    mlComponent.model = script.model;

    Hierarchy (View Summary)

    Index

    Properties

    autoRun: boolean

    Runs the MLComponent automatically when the object or component it's on is enabled.

    Lens Scripting Version 161

    false
    
    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    true
    
    inferenceMode: InferenceMode

    Controls the inference mode that MLComponent will run in. For example, GPU, CPU, etc.

    MachineLearning.InferenceMode.Auto
    
    isBeingDestroyed: boolean

    Returns true if this Component is currently being destroyed. Becomes true as soon as destruction begins via Component#destroy or destruction of its owning SceneObject, before any OnDestroyEvent callbacks fire.

    Lens Scripting Version 364

    if (!script.isBeingDestroyed) {
    // Component is still fully alive
    }
    isEnabledInHierarchy: boolean

    Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.

    model: MLAsset

    Binary ML model supplied by the user.

    null
    
    onLoadingFailed: (error: string) => void

    Bind a function that is triggered when the component fails to load a model.

    null
    
    onLoadingFinished: () => void

    Function that gets called when model loading is finished.

    null
    
    onRunningFailed: (error: string) => void

    Bind a function that is triggered when the component fails to run a model.

    null
    
    onRunningFinished: () => void

    Function that gets called when the model stops running.

    null
    
    renderOrder: number

    Render order of the MLComponent.

    0
    
    sceneObject: SceneObject

    The SceneObject this component is on.

    state: ModelState

    Returns the current status of the neural network model.

    uniqueIdentifier: string

    Lens Scripting Version 176

    Methods

    • Builds the MLComponent model when all placeholders are determined. Config is an array of Input and Output placeholders.

      Parameters

      Returns void

    • Build the MLComponent asynchronously.

      Parameters

      Returns Promise<void>

      Lens Scripting Version 323

    • Stops running the MLComponent. The onRunningFinished callback will not be executed.

      Returns void

    • Destroys the component.

      Returns void

    • Returns an array of InputPlaceholders of the MLComponent's model with default settings. Returns empty array if the model asset is not set.

      Returns InputPlaceholder[]

      Lens Scripting Version 143

    • Returns an array of OutputPlaceholders of MLComponent's model with default settings. Returns empty array if the model is not set.

      Returns OutputPlaceholder[]

      Lens Scripting Version 143

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if running is requested on each frame.

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Runs the MLComponent once.

      Parameters

      • sync: boolean

      Returns void

    • Schedules the MLComponent to run at the start timing and terminate at the end timing. The scheduled running will recur if recurring is true.

      Parameters

      Returns void

    • Stops running the MLComponent.

      Returns void

    • If loading asynchronously, makes the entire system wait until loading is finished.

      Returns void

    • If running asynchronously, makes the entire system wait until the last run is finished.

      Returns void