Transforms inputs (Textures or Float32Array) into outputs (Textures or Float32Array) using a neural network. The neural network is represented by an MLAsset, which is set as the model property. For more information, see the MLComponent Overview.

//@input Asset.MLAsset model
var mlComponent = script.sceneObject.createComponent('MLComponent');
mlComponent.model = script.model;
interface MLComponent {
    autoRun: boolean;
    enabled: boolean;
    inferenceMode: InferenceMode;
    model: MLAsset;
    onLoadingFinished: (() => void);
    onRunningFinished: (() => void);
    renderOrder: number;
    sceneObject: SceneObject;
    state: ModelState;
    uniqueIdentifier: string;
    build(placeholders: BasePlaceholder[]): void;
    cancel(): void;
    destroy(): void;
    getInput(name: string): InputPlaceholder;
    getInputs(): InputPlaceholder[];
    getOutput(name: string): OutputPlaceholder;
    getOutputs(): OutputPlaceholder[];
    getSceneObject(): SceneObject;
    getScheduledEnd(): FrameTiming;
    getScheduledStart(): FrameTiming;
    getTransform(): Transform;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isRecurring(): boolean;
    isSame(other: ScriptObject): boolean;
    runImmediate(sync: boolean): void;
    runScheduled(recurring: boolean, startTiming: FrameTiming, endTiming: FrameTiming): void;
    stop(): void;
    waitOnLoading(): void;
    waitOnRunning(): void;
}

Hierarchy (view full)

Properties

autoRun: boolean

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

enabled: boolean

If disabled, the Component will stop enacting its behavior.

inferenceMode: InferenceMode

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

model: MLAsset

Binary ML model supplied by the user.

onLoadingFinished: (() => void)

Function that gets called when model loading is finished.

onRunningFinished: (() => void)

Function that gets called when the model stops running.

renderOrder: number

Render order of the MLComponent.

sceneObject: SceneObject
state: ModelState

Returns the current status of the neural network model.

uniqueIdentifier: string

Methods

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

    Parameters

    Returns void

  • 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[]

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

    Returns OutputPlaceholder[]

  • 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