### Get image embeddings with InferenceHTTPClient Source: https://inference.roboflow.com/workflows/classifier_embeddings Use the InferenceHTTPClient to get image embeddings from the /infer/embeddings endpoint. The example shows synchronous calls for feature vectors and logits, accessing the embeddings and info, and notes the async API has the same arguments and result format. ```python from inference_sdk import InferenceHTTPClient client = InferenceHTTPClient("http://localhost:9001", api_key="YOUR_API_KEY") result = client.get_image_embeddings("product.jpg", model_id="my-project/3") logits = client.get_image_embeddings("product.jpg", model_id="my-project/3", output_type="logits") vector = result["embeddings"][0] info = result["embedding_info"] # The async API has the same arguments and result format. # result = await client.get_image_embeddings_async("product.jpg", "my-project/3") ``` -------------------------------- ### Direct model use with AutoModel.from_pretrained and embed_images Source: https://inference.roboflow.com/workflows/classifier_embeddings Shows how to load a model with the image_embeddings capability and generate feature vectors or logits. The output_type parameter selects which graph to preload; direct calls can override it on first use. Requires an API key and the inference-models package. ```python from inference_models import AutoModel model = AutoModel.from_pretrained( "my-project/3", api_key="YOUR_API_KEY", required_capabilities=["image_embeddings"], output_type="feature_vector", # Or "logits"; selects which graph to preload. ) features = model.embed_images(images, input_color_format="bgr") # Direct calls can also override the output type, preparing that graph on first use. logits = model.embed_images(images, output_type="logits", input_color_format="bgr") ``` -------------------------------- ### InferenceHTTPClient.get_image_embeddings_async Source: https://inference.roboflow.com/workflows/classifier_embeddings Asynchronous SDK method to generate image embeddings. Same arguments and result format as the synchronous version. ```APIDOC ## InferenceHTTPClient.get_image_embeddings_async ### Description Asynchronous SDK method to generate image embeddings. Same arguments and result format as the synchronous version. ### Method SDK Call (Async) ### Endpoint await client.get_image_embeddings_async(image, model_id, output_type=None) ### Parameters - **image** (string) - Required - Path to the input image. - **model_id** (string) - Required - The model identifier, e.g., "my-project/3". - **output_type** (string) - Optional - Set to "logits" to get logits; omit for feature vectors. ### Request Example # result = await client.get_image_embeddings_async("product.jpg", "my-project/3") ### Response #### Success Response - **embeddings** (array) - List of embedding vectors. - **embedding_info** (object) - Metadata for each embedding. - **time** (number) - Inference time. - **metadata** (object) - Inference metadata. #### Response Example { "embeddings": [[0.1, 0.2, ...]], "embedding_info": { "model_version": "3", "output_type": "feature_vector", "feature_definition": "...", "vector_dimension": 768, "normalization": "...", "space_id": "..." }, "time": 0.123, "metadata": {} } ``` -------------------------------- ### InferenceHTTPClient.get_image_embeddings Source: https://inference.roboflow.com/workflows/classifier_embeddings Synchronous SDK method to generate image embeddings. Accepts an image path and model ID, with optional output_type. ```APIDOC ## InferenceHTTPClient.get_image_embeddings ### Description Synchronous SDK method to generate image embeddings. Accepts an image path and model ID, with optional output_type. ### Method SDK Call ### Endpoint client.get_image_embeddings(image, model_id, output_type=None) ### Parameters - **image** (string) - Required - Path to the input image. - **model_id** (string) - Required - The model identifier, e.g., "my-project/3". - **output_type** (string) - Optional - Set to "logits" to get logits; omit for feature vectors. ### Request Example from inference_sdk import InferenceHTTPClient client = InferenceHTTPClient("http://localhost:9001", api_key="YOUR_API_KEY") result = client.get_image_embeddings("product.jpg", model_id="my-project/3") logits = client.get_image_embeddings("product.jpg", model_id="my-project/3", output_type="logits") ### Response #### Success Response - **embeddings** (array) - List of embedding vectors. - **embedding_info** (object) - Metadata for each embedding. - **time** (number) - Inference time. - **metadata** (object) - Inference metadata. #### Response Example { "embeddings": [[0.1, 0.2, ...]], "embedding_info": { "model_version": "3", "output_type": "feature_vector", "feature_definition": "...", "vector_dimension": 768, "normalization": "...", "space_id": "..." }, "time": 0.123, "metadata": {} } ``` -------------------------------- ### Workflow definition for embedding model Source: https://inference.roboflow.com/workflows/classifier_embeddings Defines a workflow step using the roboflow_core/embedding_model@v1 block with model_id resnet101 and output_type feature_vector. The outputs select the embedding and embedding_info fields. ```json { "version": "1.0", "inputs": [{"type": "InferenceImage", "name": "image"}], "steps": [{ "type": "roboflow_core/embedding_model@v1", "name": "embedding", "data": "$inputs.image", "model_id": "resnet101", "output_type": "feature_vector" }], "outputs": [ {"type": "JsonField", "name": "embedding", "selector": "$steps.embedding.embedding"}, {"type": "JsonField", "name": "embedding_info", "selector": "$steps.embedding.embedding_info"} ] } ``` -------------------------------- ### POST /infer/embeddings Source: https://inference.roboflow.com/workflows/classifier_embeddings Generates image embeddings from a classification model. Accepts an image or list of images and returns embeddings along with metadata. ```APIDOC ## POST /infer/embeddings ### Description Generates image embeddings (feature vectors or logits) from a classification model. Accepts an image or list of images and returns embeddings along with metadata. ### Method POST ### Endpoint /infer/embeddings ### Parameters #### Request Body - **model_id** (string) - Required - The model identifier, e.g., "my-project/3". - **api_key** (string) - Required - Your API key for authentication. - **image** (image or list of images) - Required - The input image(s) in the usual Inference image format. - **output_type** (string) - Optional - Set to "feature_vector" or "logits". Omit to default to feature vectors. - **preprocessing overrides** (object) - Optional - Standard image preprocessing overrides; recorded in metadata. ### Request Example { "model_id": "my-project/3", "api_key": "YOUR_API_KEY", "image": "product.jpg", "output_type": "feature_vector" } ### Response #### Success Response (200) - **embeddings** (array) - List of embedding vectors. - **embedding_info** (object) - Metadata for each embedding, including model version, output type, feature definition, vector dimension, normalization, and space_id. - **time** (number) - Inference time. - **metadata** (object) - Inference metadata, including preprocessing details. #### Response Example { "embeddings": [[0.1, 0.2, ...]], "embedding_info": { "model_version": "3", "output_type": "feature_vector", "feature_definition": "...", "vector_dimension": 768, "normalization": "...", "space_id": "..." }, "time": 0.123, "metadata": {} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.