Core Models
Call CLIP and DocTR foundation models through the inference-sdk HTTP client, with sync and async methods.
InferenceHTTPClient supports core models hosted by Inference. Some of these models can be used on the Roboflow hosted inference platform (use https://serverless.roboflow.com as the URL); others can be deployed locally (usually the local server is available at http://localhost:9001).
CLIP
from inference_sdk import InferenceHTTPClient, InferenceConfiguration
CLIENT = InferenceHTTPClient(
api_url="http://localhost:9001", # or "https://serverless.roboflow.com" to use hosted serving
api_key="ROBOFLOW_API_KEY"
).configure(InferenceConfiguration(api_key_transport="header"))
CLIENT.get_clip_image_embeddings(inference_input="./my_image.jpg") # single image request
CLIENT.get_clip_image_embeddings(inference_input=["./my_image.jpg", "./other_image.jpg"]) # batch image request
CLIENT.get_clip_text_embeddings(text="some") # single text request
CLIENT.get_clip_text_embeddings(text=["some", "other"]) # other text request
CLIENT.clip_compare(
subject="./my_image.jpg",
prompt=["fox", "dog"],
)The CLIENT.clip_compare(...) method allows you to compare different combinations of subject_type and prompt_type:
(image, image)(default)(image, text)(text, image)(text, text)
Async methods are also available:
See the CLIP model reference for details about the model itself.
DocTR
Async equivalent: CLIENT.ocr_image_async(...). See the DocTR model reference for details.
Gaze (deprecated)
Last updated
Was this helpful?