pixano_inference.models.embedding
Embedding model base class.
A single capability that embeds either an image or text into a shared vector space
(CLIP-style), so image and text embeddings are directly comparable (text-to-image search). The
I/O types live in :mod:pixano_inference_client.embedding and are re-exported here so
from pixano_inference.models.embedding import EmbeddingInput keeps working.
EmbeddingModel(config)
Bases: InferenceModel
Base class for image/text embedding models (CLIP-style shared space).
Example
@register_model("my-embedder")
class MyEmbedder(EmbeddingModel):
def load_model(self):
self.model = load_weights(self.config.model_params["path"])
def predict(self, input: EmbeddingInput) -> EmbeddingOutput:
vectors = self.model.encode(input.image or input.text)
return EmbeddingOutput(embeddings=NDArrayFloat.from_numpy(vectors), dim=vectors.shape[-1])
Source code in pixano_inference/models/base.py
predict(input)
abstractmethod
Compute embeddings for the given image(s) or text(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
EmbeddingInput
|
Embedding input with exactly one of image/text. |
required |
Returns:
| Type | Description |
|---|---|
EmbeddingOutput
|
Embedding output with a |