Fast, scalable whole-slide encoding
https://clemsgrs.github.io/slide2vec ↗// readme
slide2vec
slide2vec encodes whole-slide images with publicly available pathology foundation models. It uses hs2p for tissue detection and tiling, and handles batching, multi-GPU execution, and embedding storage.
Install
Python 3.10 or newer is required:
pip install slide2vec
Many models need additional dependencies available through pip install "slide2vec[fm]". See the model installation guide for model-specific extras, separate environments, and upstream packages.
For gated models such as Virchow2, request access on the model’s Hugging Face page and authenticate with hf auth login or an HF_TOKEN environment variable.
Embed a slide
from slide2vec import Model, PreprocessingConfig
model = Model.from_preset("virchow2")
preprocessing = PreprocessingConfig(requested_spacing_um=0.5)
embedded = model.embed_slide("/path/to/slide.svs", preprocessing=preprocessing)
tile_embeddings = embedded.tile_embeddings # (N, 2560)
x, y = embedded.x, embedded.y # level-0 tile coordinates
The preset supplies tile size and…