Skip to main content

SigLIP 2 Embedder API and CLI

This project provides a microservice and a command-line interface (CLI) to generate text and image embeddings using Google's SigLIP 2 models. It is built with FastAPI for the API and Hugging Face transformers for model inference.

✨ Features

  • Dual Mode: Can run as a REST API server or a command-line tool (CLI).
  • Text & Image Embedding: Generates normalized embeddings for text and image inputs.
  • Flexible Output: The CLI can print embeddings to standard output or save them to JSON or pickle files.
  • Layered Configuration: Manages settings via a default config.yaml, which can be overridden by a custom config file.
  • Auto Hardware Detection: Automatically detects and uses a GPU (CUDA) if available for faster performance.
  • Documented API: The API interface is automatically documented via Swagger UI (/docs) and ReDoc (/redoc).

Table of Contents


🚀 Installation

  1. Clone the repository.
  2. Create a virtual environment (recommended).
  3. Install dependencies. The project uses the dependencies listed in pyproject.toml.

or

```bash pip install siglip2-embedder-api ```


⚙️ Configuration

You can configure the application's behavior by editing the config.yaml file, which is loaded by default if it exists.

  • device: Defines the compute device. If set to auto, the system will use cuda if available; otherwise, it will fall back to cpu.
  • model_name: The identifier of the SigLIP 2 model to download from Hugging Face.
  • server_host: IP address for the server to bind to.
  • server_port: Port for the server to run on.

You can override these settings in two ways when running the application:

  1. Custom Config File: By passing the --config argument with a path to your own YAML file. Settings in this file will override config.yaml.
  2. Direct Arguments: By passing specific arguments like --device or --model-name (see CLI mode). These override all config files.

▶️ Usage

The application can run in two modes: server (default) or cli.

Server (API) Mode

This mode starts a FastAPI web server, exposing endpoints for generating embeddings.

By default, the server will be available at http://0.0.0.0:8000. You can change this with command-line arguments.

API Endpoints

  • GET /
    • Description: Displays a welcome message.
  • POST /embed/text
    • Description: Generates an embedding for a given text.
  • POST /embed/image
    • Description: Generates an embedding for an image.

Once the server is running, you can access the interactive documentation at:

  • Swagger UI: http://127.0.0.1:8000/docs
  • ReDoc: http://127.0.0.1:8000/redoc

CLI Mode

This mode allows you to generate embeddings directly from your terminal without starting a web server.

The result will be printed to the console unless an --output file is specified.

Overriding Configuration from the CLI

You can change settings without editing the config.yaml file by using command-line arguments.

  • To use a custom configuration file:

    siglip2-embedder --mode cli --config my_custom_config.yaml --text "Hello world"
    
  • To override specific settings:

    siglip2-embedder --mode cli --model-name "google/siglip2-base-patch16-224" --device "cpu" --text "This runs on the CPU"
    

📂 Project Structure

  • main.py: Contains the main application logic (CLI and API).
  • config.yaml: Default configuration file.
  • pyproject.toml: Project definition and dependencies.
  • README.md: This file.

Metadata

Release files for siglip2-embedder-api 1.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for siglip2-embedder-api 1.4.3
File Size Uploaded Provenance Actions
siglip2_embedder_api-1.4.3.tar.gz 7.1 kB Without provenance Details for siglip2_embedder_api-1.4.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for siglip2-embedder-api 1.4.3
File Interpreter ABI Platform Actions
siglip2_embedder_api-1.4.3-py3-none-any.whl Python 3 none any Details for siglip2_embedder_api-1.4.3-py3-none-any.whl

Total release size: 14.7 kB

Release files / siglip2_embedder_api-1.4.3.tar.gz

Download URL siglip2_embedder_api-1.4.3.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7781e479cf752abbb5ef3f9e9d590df516003cfdb7f43a72ee2146ea806be31e
BLAKE2b-256 checksum
How to use checksums
99e2f19dcd2f54e611f4e74cd05c175011a073256a73d286e2a45048cfa330b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / siglip2_embedder_api-1.4.3-py3-none-any.whl

Download URL siglip2_embedder_api-1.4.3-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a7ae954f675c61a941f3d944191ad368e6a98cece504f2517f4f6ec28548a83
BLAKE2b-256 checksum
How to use checksums
56935438364ddfc81ce8eb21a33b3c6f98b18031db5267d80a85bcf4838b8309
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Security for siglip2-embedder-api 1.4.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.4.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page