Image embeddings
This guide shows how you can create image embeddings.
The following table lists the available models for generating text embeddings and their key characteristics:
The “Marengo-Retrieval-2.7” video understanding model generates embeddings for all modalities in the same latent space. This shared space enables any-to-any searches across different types of content.
Prerequisites
-
To use the platform, you need an API key:
-
Ensure the TwelveLabs SDK is installed on your computer:
-
The images you wish to use use must meet the following requirements:
- Format: JPEG and PNG.
- Dimension: Must be at least 128 x 128 pixels.
- Size: Must not exceed 5MB.
Complete example
This complete example shows how you can create image emebddings. Ensure you replace the placeholders surrounded by <>
with your values.
Step-by-step guide
Python
Node.js
Import the SDK and initialize the client
Create a client instance to interact with the TwelveLabs Video Understanding platform.
Function call: You call the constructor of the TwelveLabs
class.
Parameters:
api_key
: The API key to authenticate your requests to the platform.
Return value: An object of type TwelveLabs
configured for making API calls.
Create image embeddings
Function call: You call the embed.create
function.
Parameters:
model_name
: The name of the model you want to use (“Marengo-retrieval-2.7”).image_file
orimage_url
: The path or the publicly accessible URL of your image file.
Return value: The response contains the following fields:
image_embedding
: An object that contains the embedding data for your image file. It includes the following fields:segments
: An object that contains the following:float
: An array of floats representing the embedding
metadata
: An object that contains metadata about the embedding.
model_name
: The name ofhe video understanding model the platform has used to create this embedding.