Skip to main content
Version: Next

Interface: StyleTransferType

Defined in: types/styleTransfer.ts:36

Return type for the useStyleTransfer hook. Manages the state and operations for applying artistic style transfer to images.

Properties

downloadProgress

downloadProgress: number

Defined in: types/styleTransfer.ts:55

Represents the download progress of the model binary as a value between 0 and 1.


error

error: RnExecutorchError | null

Defined in: types/styleTransfer.ts:40

Contains the error object if the model failed to load, download, or encountered a runtime error during style transfer.


isGenerating

isGenerating: boolean

Defined in: types/styleTransfer.ts:50

Indicates whether the model is currently processing an image.


isReady

isReady: boolean

Defined in: types/styleTransfer.ts:45

Indicates whether the style transfer model is loaded and ready to process images.


runOnFrame

runOnFrame: (frame, isFrontCamera) => PixelData | null

Defined in: types/styleTransfer.ts:87

Synchronous worklet function for real-time VisionCamera frame processing. Automatically handles native buffer extraction and cleanup.

Use this for VisionCamera frame processing in worklets. For async processing, use forward() instead.

Available after model is loaded (isReady: true).

Param

VisionCamera Frame object

Param

Whether the front camera is active, used for mirroring corrections.

Returns

PixelData containing the stylized frame as raw RGB pixel data.

Methods

forward()

forward<O>(input, outputType?): Promise<O extends "url" ? string : PixelData>

Defined in: types/styleTransfer.ts:70

Executes the model's forward pass to apply the specific artistic style to the provided image.

Supports two input types:

  1. String path/URI: File path, URL, or Base64-encoded string
  2. PixelData: Raw pixel data from image libraries (e.g., NitroImage)

Note: For VisionCamera frame processing, use runOnFrame instead.

Type Parameters

O

O extends "pixelData" | "url" = "pixelData"

Parameters

input

Image source (string or PixelData object)

string | PixelData

outputType?

O

Output format: 'pixelData' (default) returns raw RGBA pixel data; 'url' saves the result to a temp file and returns its file:// path.

Returns

Promise<O extends "url" ? string : PixelData>

A Promise resolving to PixelData when outputType is 'pixelData' (default), or a file:// URL string when outputType is 'url'.

Throws

If the model is not loaded or is currently processing another image.