Skip to content

Classification

siglip2_toolkit.classification.ImageClassifier

ImageClassifier(
    model,
    device="auto",
    dtype=None,
    num_labels=None,
    trust_remote_code=False,
)

Classifies images with a fine-tuned image-classification model.

The model and its image processor are loaded lazily on first use. Labels come from the checkpoint's config.id2label; num_labels overrides the head size when the checkpoint requires it.

labels property

labels

id -> label mapping (empty until the model is loaded).

load

load()

Load the model and its image processor from a local directory (idempotent).

classify

classify(images, top_k=None, batch_size=16)

Classify images; returns (label, probability) pairs sorted by score.