Skip to content

pixano_inference.schemas.embedding

Embedding I/O types.

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).

EmbeddingInput(**data)

Bases: _BaseModel

Input for embedding computation.

Exactly one of image or text must be provided. Either may be a single value or a list (batch). Images are passed by value (path/URL/base64/bytes) and resolved through the media security policy.

Attributes:

Name Type Description
image list[str | Path | bytes] | str | Path | bytes | None

Image(s) to embed (path, URL, base64, or raw bytes).

text list[str] | str | None

Text(s) to embed.

normalize bool

Whether to L2-normalize the output vectors (default True).

Source code in pydantic/main.py
def __init__(self, /, **data: Any) -> None:
    """Create a new model by parsing and validating input data from keyword arguments.

    Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be
    validated to form a valid model.

    `self` is explicitly positional-only to allow `self` as a field name.
    """
    # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    __tracebackhide__ = True
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    if self is not validated_self:
        warnings.warn(
            'A custom validator is returning a value other than `self`.\n'
            "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
            f'See the `model_validator` docs (https://pydantic.dev/docs/validation/{version_short()}/concepts/validators/#model-validators) for more details.',
            stacklevel=2,
        )

EmbeddingOutput(**data)

Bases: _BaseModel

Output for embedding computation.

Attributes:

Name Type Description
embeddings NDArrayFloat

Embedding vectors as a [num_inputs, dim] array.

dim int

Dimensionality of each embedding vector.

Source code in pydantic/main.py
def __init__(self, /, **data: Any) -> None:
    """Create a new model by parsing and validating input data from keyword arguments.

    Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be
    validated to form a valid model.

    `self` is explicitly positional-only to allow `self` as a field name.
    """
    # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    __tracebackhide__ = True
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    if self is not validated_self:
        warnings.warn(
            'A custom validator is returning a value other than `self`.\n'
            "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
            f'See the `model_validator` docs (https://pydantic.dev/docs/validation/{version_short()}/concepts/validators/#model-validators) for more details.',
            stacklevel=2,
        )