Embedder¶
siglip2_toolkit.embedder.Embedder ¶
Generates text and image embeddings with a SigLIP 2 model.
model is a local model directory; model_id is the identifier
recorded in logs and in the embedding-space manifest (defaults to the
path). Load the model from the toolkit cache with
siglip2_toolkit.models.resolve_model.
Embeddings are L2-normalised float32 numpy arrays. The instance is
safe to share across threads (inference is serialised with an internal
lock); it is not safe to share across processes.
embed_texts ¶
Embed a batch of texts. Returns a (n, dimensions) float32 array.
embed_images ¶
Embed a batch of images.
images items may be paths, bytes, file-like objects or PIL images.
With on_error="skip" unreadable items are logged and skipped; the
kept positions are returned alongside the matrix when
return_indices=True.
zero_shot_logits ¶
Raw zero-shot classification logits, shaped (n_images, n_labels).
Scores follow the SigLIP recipe: cosine similarity between normalised
embeddings, scaled by the model's learned logit_scale and shifted
by logit_bias. template wraps each label ({} is replaced
by the label). When the model has no learned scale (non-SigLIP
checkpoints), a CLIP-style temperature of 100 is used.
classify ¶
Zero-shot image classification.
Returns, for each image, (label, probability) pairs sorted by
decreasing softmax probability over the candidate labels (mutually
exclusive assumption). Use zero_shot_logits when you need the
raw scores for custom decision rules.