react-native-fast-tflite
Version:
High-performance TensorFlow Lite library for React Native, built with Nitro Modules
25 lines • 1.28 kB
TypeScript
import type { TfliteModel, TensorflowModelDelegate } from './specs/Tflite.nitro';
import { type ModelSource } from './loadTensorflowModel';
export type TensorflowPlugin = {
model: TfliteModel;
state: 'loaded';
} | {
model: undefined;
state: 'loading';
} | {
model: undefined;
error: Error;
state: 'error';
};
/**
* Load a Tensorflow Lite Model from the given `.tflite` asset into a React State.
*
* * If you are passing in a `.tflite` model from your app's bundle using `require(..)`, make sure to add `tflite` as an asset extension to `metro.config.js`!
* * If you are passing in a `{ url: ... }`, make sure the URL points directly to a `.tflite` model. This can either be a web URL (`http://..`/`https://..`), or a local file (`file://..`).
*
* @param source The `.tflite` model in form of either a `require(..)` statement or a `{ url: string }`.
* @param delegates The delegates to use for computations. Uses the standard CPU delegate per default. The `core-ml` or `metal` delegates are GPU-accelerated, but don't work on every model.
* @returns The state of the Model.
*/
export declare function useTensorflowModel(source: ModelSource, delegates: TensorflowModelDelegate[]): TensorflowPlugin;
//# sourceMappingURL=useTensorflowModel.d.ts.map