Skip to main content
Version: Next

ImageEmbeddingsModule

TypeScript API implementation of the useImageEmbeddings hook.

API Reference

High Level Overview

import {
ImageEmbeddingsModule,
CLIP_VIT_BASE_PATCH32_IMAGE,
} from 'react-native-executorch';

// Creating an instance
const imageEmbeddingsModule = new ImageEmbeddingsModule();

// Loading the model
await imageEmbeddingsModule.load(CLIP_VIT_BASE_PATCH32_IMAGE);

// Running the model
const embedding = await imageEmbeddingsModule.forward(
'https://url-to-image.jpg'
);

Methods

All methods of ImageEmbeddingsModule are explained in details here: ImageEmbeddingsModule API Reference

Loading the model

To initialize the module, create an instance and call the load method with the following parameters:

This method returns a promise, which can resolve to an error or void.

For more information on loading resources, take a look at loading models page.

Running the model

forward accepts one argument, which is a URI/URL to an image you want to encode. The function returns a promise, which can resolve either to an error or an array of numbers representing the embedding.