Skip to content

Models

siglip2_toolkit.models

Toolkit model cache: the toolkit's own store of models.

Everything the toolkit uses lives here, or is a local path you provide. The HuggingFace cache is unrelated: this toolkit never reads it. The only network access in the whole toolkit is download_model (the siglip2 models download command).

Layout::

<home>/                      # default: ~/.local/share/siglip2-toolkit
├── config.json              # {"cache_dir": "...", "current": "..."}
└── models/
    └── google--siglip2-base-patch16-naflex/
        ├── model.json       # provenance: identifier, source, origin, date
        └── ...              # model files (config.json, weights, processor)

config.json is created on first use with the defaults already written, so you can see and edit them (e.g. point cache_dir at another disk). There are no environment variables.

CatalogModel dataclass

CatalogModel(id, params, patch, resolution, approx_size)

One entry of the informational SigLIP 2 catalog (nothing is automatic).

ModelEntry dataclass

ModelEntry(
    identifier, path, source, origin, created_at, size_bytes
)

A model stored in the toolkit cache.

ResolvedModel dataclass

ResolvedModel(path, identifier)

A model resolved to a local directory, plus its identifier.

toolkit_home

toolkit_home(home=None)

The toolkit home directory (explicit for non-default installations).

config_path

config_path(home=None)

Path of the toolkit config.json.

ensure_config

ensure_config(home=None)

Read config.json, creating it with visible defaults on first use.

save_config

save_config(config, home=None)

Write the toolkit config.json.

cache_dir

cache_dir(home=None)

The model cache directory, as configured in config.json.

Accepts absolute paths or paths relative to the toolkit home.

default_device

default_device(home=None)

The device configured in config.json ("auto" when unset).

flatten

flatten(identifier)

Cache entry directory name for an identifier (org/name → org--name).

list_models

list_models(home=None)

List the models stored in the toolkit cache.

find_model

find_model(identifier, home=None)

Find a cache entry by identifier (or by its flattened directory name).

current_identifier

current_identifier(home=None)

The identifier of the model in use, or None.

set_current

set_current(identifier, home=None)

Set the model in use (it must already be in the cache).

is_model_directory

is_model_directory(path)

Whether path looks like a loadable transformers model directory.

download_model

download_model(identifier, revision=None, home=None)

Download a HuggingFace model into the toolkit cache (the network path).

This is the only function in the toolkit that uses the network.

import_model

import_model(path, name=None, home=None)

Copy a model from a local path into the toolkit cache.

The source directory is never modified. name sets the identifier (defaults to the folder name).

delete_model

delete_model(identifier, home=None)

Delete a model from the toolkit cache (refuses the model in use).

resolve_model

resolve_model(model=None, home=None)

Resolve a model reference to a local directory.

Accepted references: an identifier in the toolkit cache, or a path to a local model directory. With model=None the model in use is used, or the built-in default. Never touches the network.