Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,24 @@ export async function createClassifier<L>(
config: ClassifierModel<L>,
runtime?: WorkletRuntime
): Promise<{
/**
* Releases all allocated native resources.
*/
dispose: () => void;
/**
* Performs asynchronous image classification on the given input image.
* @param input The input image buffer.
* @param options Configuration options for classification.
* @param options.topk The number of top-scoring classification results to
* return. If omitted, all classes are returned. Must be non-negative.
* @returns A promise resolving to the list of classifications sorted by
* confidence.
*/
classify: (input: ImageBuffer, options?: { topk?: number }) => Promise<Classification<L>[]>;
/**
* Synchronous version of {@link classify} to be executed directly on the
* caller or worklet thread.
*/
classifyWorklet: (input: ImageBuffer, options?: { topk?: number }) => Classification<L>[];
}> {
const { modelPath, classifierOpts } = config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,21 @@ export function createImagePreprocessor(
opts: ImagePreprocessorOptions,
outputShape: number[]
): {
/**
* Preprocesses the input image by resizing, converting color space, changing
* format layout, and normalizing values, copying the output directly to the
* pre-allocated output tensor.
*
* Note: The returned tensor is managed by the preprocessor; consumers do not
* need to dispose of it manually.
* @param input The input image buffer to preprocess.
* @returns A reference to the output tensor containing preprocessed float32
* data.
*/
process: (input: ImageBuffer) => Tensor;
/**
* Releases all allocated native resources.
*/
dispose: () => void;
} {
const numRgbChannels = 3;
Expand Down