Encoders¶
Select a frozen encoder by name: FeaturesConfig(encoder="uni2") in Python,
features.encoder.name in YAML. An encoder is a leaf of the encoder registry: a name
plus its params (output_variant, allow_non_recommended_settings).
Precision and batch size are execution settings (slide2vec’s
ExecutionOptions); Preprocessing controls image geometry.
Encoding methods
Single encoder — pick one preset from the model zoo below (the common case).
Composite (multi-encoder) — concatenate several presets into one richer per-position vector: details.
The run’s features are configured by soma.config.FeaturesConfig, which holds
the encoder leaf (soma.config.EncoderLeaf) next to slide2vec’s
PreprocessingConfig, ExecutionOptions and DenseOptions.
- class soma.config.FeaturesConfig(kind='cached', encoder=None, extraction=<factory>, execution=<factory>, dense=None, cache=<factory>, spacing_policy='strict')¶
Bases:
Editablefeatures: where a run’s features come from (ADR 0019).kind:cachedextracts once;livere-encodes the (augmented) pixels every step (grid shape).encoder: a slide2vec encoder orcomposite(Nonewhen the run is handed its features).extraction,executionanddenseare slide2vec’sPreprocessingConfig,ExecutionOptionsandDenseOptions, held as given; an unset tiling comes fromdense(grid) or the encoder preset.spacing_policy: native_if_coarserreads a coarser sample at its native spacing.
- class soma.config.EncoderLeaf(name, params=<factory>)¶
Bases:
ComponentThe frozen encoder: a slide2vec encoder, or
compositefor several concatenated.paramsare slide2vec’sModel.from_presetkeywords (output_variant,allow_non_recommended_settings), or the composite’s members (soma.models.encoders.CompositeParams); theencodersregistry validates them.
Model Zoo¶
Tile encoders are grouped by output dimension. Spacing is in µm/px; multiple
dimensions indicate output variants. soma.components("encoders") lists the
presets installed in slide2vec’s registry, each with its level; soma list
encoders --level tile prints one level.
Tile-level encoders¶
Preset |
Model |
Output dim |
Spacing |
|---|---|---|---|
|
384 |
|
|
|
384 |
|
|
|
384 / 768 |
|
|
|
512 |
|
|
|
768 |
|
|
|
768 |
|
|
|
768 |
|
|
|
768 / 1536 |
|
|
|
768 / 1536 |
|
|
|
1024 |
|
|
|
1024 |
|
|
|
1024 |
|
|
|
1024 / 2048 |
|
|
|
1024 |
|
|
|
1024 |
|
|
|
1024 |
|
|
|
1024 |
|
|
|
1280 / 2560 |
|
|
|
1280 / 2560 |
|
|
|
1536 |
|
|
|
1536 |
|
|
|
1536 |
|
|
|
1536 |
|
|
|
1536 / 3072 |
|
|
|
1536 |
|
|
|
1536 / 3072 |
|
|
|
3072 |
|
|
|
4608 |
|
Natural-image controls¶
Non-pathology baselines that share the tile-encoder interface, for measuring how much pathology pretraining contributes. Both are spacing agnostic, with 0.5 µm/px as the default; see Preprocessing for their tile sizes.
Preset |
Model |
Output dim |
Spacing |
|---|---|---|---|
|
768 |
|
|
|
768 |
|
DINOv3 uses patch_mean pooling by default; select
encoder.output_variant: cls for its class-token output.
Slide-level encoders¶
Preset |
Model |
Tile encoder |
Output dim |
|---|---|---|---|
|
|
768 |
|
|
|
768 |
|
|
|
1280 |
|
|
|
2560 ( |
|
|
|
768 |
A slide-level encoder gives one vector per slide, which goes straight to the task
head: the run takes no aggregator. The slide_classification, slide_regression
and slide_survival presets train on it (see Use cases); the other presets
refuse a slide-level encoder and name the one to use. soma.plan.check() refuses
an aggregator with a slide-level encoder. It also refuses a slide- or patient-level
encoder in a segmentation or detection run, which encodes tiles and needs a tile-level
encoder.
Patient-level encoders¶
Preset |
Model |
Tile encoder |
Output dim |
|---|---|---|---|
|
|
768 |
A patient-level encoder gives one vector per patient: set cohort.collapse:
patient_id. No preset covers patient-level encoders yet, so write the config.
Set features.extraction.tiling.requested_spacing_um explicitly for encoders with multiple
recommended spacings. For a single recommended spacing, soma can fill it in.
Configuration and runtime validation check the final combination.