slide2vec 2.0.1__tar.gz → 3.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. slide2vec-3.0.0/PKG-INFO +166 -0
  2. slide2vec-3.0.0/README.md +110 -0
  3. {slide2vec-2.0.1 → slide2vec-3.0.0}/pyproject.toml +1 -1
  4. {slide2vec-2.0.1 → slide2vec-3.0.0}/setup.cfg +11 -4
  5. slide2vec-3.0.0/slide2vec/__init__.py +17 -0
  6. slide2vec-3.0.0/slide2vec/__main__.py +5 -0
  7. slide2vec-3.0.0/slide2vec/api.py +376 -0
  8. slide2vec-3.0.0/slide2vec/artifacts.py +187 -0
  9. slide2vec-3.0.0/slide2vec/cli.py +65 -0
  10. slide2vec-3.0.0/slide2vec/configs/__init__.py +5 -0
  11. slide2vec-3.0.0/slide2vec/configs/models/conch.yaml +44 -0
  12. slide2vec-3.0.0/slide2vec/configs/models/default.yaml +36 -0
  13. slide2vec-3.0.0/slide2vec/configs/models/h-optimus-0.yaml +37 -0
  14. slide2vec-3.0.0/slide2vec/configs/models/h-optimus-1.yaml +16 -0
  15. slide2vec-3.0.0/slide2vec/configs/models/h0-mini.yaml +20 -0
  16. slide2vec-3.0.0/slide2vec/configs/models/hibou.yaml +19 -0
  17. slide2vec-3.0.0/slide2vec/configs/models/kaiko-midnight.yaml +18 -0
  18. slide2vec-3.0.0/slide2vec/configs/models/kaiko.yaml +19 -0
  19. slide2vec-3.0.0/slide2vec/configs/models/musk.yaml +18 -0
  20. slide2vec-3.0.0/slide2vec/configs/models/panda-vit-s.yaml +23 -0
  21. slide2vec-3.0.0/slide2vec/configs/models/pathojepa.yaml +40 -0
  22. slide2vec-3.0.0/slide2vec/configs/models/phikonv2.yaml +18 -0
  23. slide2vec-3.0.0/slide2vec/configs/models/prism.yaml +24 -0
  24. slide2vec-3.0.0/slide2vec/configs/models/prov-gigapath-slide.yaml +18 -0
  25. slide2vec-3.0.0/slide2vec/configs/models/prov-gigapath-tile.yaml +16 -0
  26. slide2vec-3.0.0/slide2vec/configs/models/titan.yaml +18 -0
  27. slide2vec-3.0.0/slide2vec/configs/models/uni.yaml +39 -0
  28. slide2vec-3.0.0/slide2vec/configs/models/uni2.yaml +24 -0
  29. slide2vec-3.0.0/slide2vec/configs/models/virchow.yaml +34 -0
  30. slide2vec-3.0.0/slide2vec/configs/models/virchow2.yaml +35 -0
  31. slide2vec-3.0.0/slide2vec/configs/preprocessing/default.yaml +54 -0
  32. slide2vec-3.0.0/slide2vec/data/dataset.py +79 -0
  33. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/distributed/__init__.py +0 -13
  34. slide2vec-3.0.0/slide2vec/distributed/direct_embed_worker.py +118 -0
  35. slide2vec-3.0.0/slide2vec/distributed/pipeline_worker.py +80 -0
  36. slide2vec-3.0.0/slide2vec/inference.py +1708 -0
  37. slide2vec-3.0.0/slide2vec/main.py +8 -0
  38. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/layers/attention.py +5 -4
  39. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/layers/block.py +5 -4
  40. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/layers/swiglu_ffn.py +5 -4
  41. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/models.py +333 -273
  42. slide2vec-3.0.0/slide2vec/models/vision_transformer_pathojepa.py +171 -0
  43. slide2vec-3.0.0/slide2vec/progress.py +396 -0
  44. slide2vec-3.0.0/slide2vec/resources.py +23 -0
  45. slide2vec-3.0.0/slide2vec/utils/__init__.py +37 -0
  46. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/utils/config.py +16 -34
  47. slide2vec-3.0.0/slide2vec/utils/coordinates.py +15 -0
  48. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/utils/log_utils.py +15 -1
  49. slide2vec-3.0.0/slide2vec/utils/paths.py +10 -0
  50. slide2vec-3.0.0/slide2vec/utils/tiling_io.py +138 -0
  51. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/utils/utils.py +8 -43
  52. slide2vec-3.0.0/slide2vec.egg-info/PKG-INFO +166 -0
  53. slide2vec-3.0.0/slide2vec.egg-info/SOURCES.txt +77 -0
  54. slide2vec-3.0.0/slide2vec.egg-info/entry_points.txt +2 -0
  55. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec.egg-info/requires.txt +5 -3
  56. slide2vec-3.0.0/tests/test_hs2p_package_cutover.py +146 -0
  57. slide2vec-3.0.0/tests/test_output_consistency.py +175 -0
  58. slide2vec-3.0.0/tests/test_progress.py +299 -0
  59. slide2vec-3.0.0/tests/test_regression_core.py +481 -0
  60. slide2vec-3.0.0/tests/test_regression_inference.py +942 -0
  61. slide2vec-3.0.0/tests/test_regression_models.py +389 -0
  62. slide2vec-2.0.1/PKG-INFO +0 -138
  63. slide2vec-2.0.1/README.md +0 -84
  64. slide2vec-2.0.1/slide2vec/__init__.py +0 -6
  65. slide2vec-2.0.1/slide2vec/aggregate.py +0 -207
  66. slide2vec-2.0.1/slide2vec/configs/__init__.py +0 -20
  67. slide2vec-2.0.1/slide2vec/data/dataset.py +0 -127
  68. slide2vec-2.0.1/slide2vec/embed.py +0 -374
  69. slide2vec-2.0.1/slide2vec/main.py +0 -198
  70. slide2vec-2.0.1/slide2vec/utils/__init__.py +0 -7
  71. slide2vec-2.0.1/slide2vec.egg-info/PKG-INFO +0 -138
  72. slide2vec-2.0.1/slide2vec.egg-info/SOURCES.txt +0 -38
  73. {slide2vec-2.0.1 → slide2vec-3.0.0}/LICENSE +0 -0
  74. {slide2vec-2.0.1 → slide2vec-3.0.0}/MANIFEST.in +0 -0
  75. {slide2vec-2.0.1 → slide2vec-3.0.0}/setup.py +0 -0
  76. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/data/__init__.py +0 -0
  77. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/data/augmentations.py +0 -0
  78. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/__init__.py +0 -0
  79. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/layers/__init__.py +0 -0
  80. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/layers/dino_head.py +0 -0
  81. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/layers/drop_path.py +0 -0
  82. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/layers/layer_scale.py +0 -0
  83. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/layers/mlp.py +0 -0
  84. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/layers/patch_embed.py +0 -0
  85. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/vision_transformer_dino.py +0 -0
  86. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec/models/vision_transformer_dinov2.py +0 -0
  87. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec.egg-info/dependency_links.txt +0 -0
  88. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec.egg-info/not-zip-safe +0 -0
  89. {slide2vec-2.0.1 → slide2vec-3.0.0}/slide2vec.egg-info/top_level.txt +0 -0
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.4
2
+ Name: slide2vec
3
+ Version: 3.0.0
4
+ Summary: Embedding of whole slide images with Foundation Models
5
+ Home-page: https://github.com/clemsgrs/slide2vec
6
+ Author: Clément Grisi
7
+ Author-email: clement.grisi@radboudumc.nl
8
+ Project-URL: Bug Tracker, https://github.com/clemsgrs/slide2vec/issues
9
+ Platform: unix
10
+ Platform: linux
11
+ Platform: osx
12
+ Platform: cygwin
13
+ Platform: win32
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: hs2p<3,>=2.0
24
+ Requires-Dist: omegaconf
25
+ Requires-Dist: h5py
26
+ Requires-Dist: huggingface-hub
27
+ Requires-Dist: numpy<2
28
+ Requires-Dist: pandas
29
+ Requires-Dist: pillow
30
+ Requires-Dist: rich
31
+ Requires-Dist: tqdm
32
+ Requires-Dist: torchvision
33
+ Requires-Dist: wholeslidedata<0.0.16
34
+ Requires-Dist: matplotlib
35
+ Requires-Dist: timm
36
+ Requires-Dist: torch
37
+ Requires-Dist: transformers
38
+ Requires-Dist: environs
39
+ Requires-Dist: sacremoses
40
+ Requires-Dist: einops
41
+ Requires-Dist: einops-exts
42
+ Requires-Dist: xformers
43
+ Requires-Dist: wandb
44
+ Provides-Extra: testing
45
+ Requires-Dist: pytest>=6.0; extra == "testing"
46
+ Requires-Dist: pytest-cov>=2.0; extra == "testing"
47
+ Requires-Dist: mypy>=0.910; extra == "testing"
48
+ Requires-Dist: flake8>=3.9; extra == "testing"
49
+ Requires-Dist: tox>=3.24; extra == "testing"
50
+ Dynamic: author-email
51
+ Dynamic: description
52
+ Dynamic: description-content-type
53
+ Dynamic: home-page
54
+ Dynamic: license-file
55
+ Dynamic: project-url
56
+
57
+ # slide2vec
58
+
59
+ [![PyPI version](https://img.shields.io/pypi/v/slide2vec?label=pypi&logo=pypi&color=3776AB)](https://pypi.org/project/slide2vec/)
60
+
61
+ `slide2vec` is a Python package for efficient encoding of whole-slide images using publicly available foundation models. It builds on [`hs2p`](https://pypi.org/project/hs2p/) for fast preprocessing and exposes a focused surface around `Model`, `Pipeline`, and `ExecutionOptions`.
62
+
63
+ ## Installation
64
+
65
+ ```shell
66
+ pip install slide2vec
67
+ ```
68
+
69
+ ## Python API
70
+
71
+ ```python
72
+ from slide2vec import Model, PreprocessingConfig
73
+
74
+ model = Model.from_pretrained("virchow2", level="region")
75
+ preprocessing = PreprocessingConfig(
76
+ target_spacing_um=0.5,
77
+ target_tile_size_px=224,
78
+ tissue_threshold=0.1,
79
+ )
80
+ embedded = model.embed_slide(
81
+ "/path/to/slide.svs",
82
+ preprocessing=preprocessing,
83
+ )
84
+
85
+ tile_embeddings = embedded.tile_embeddings
86
+ coordinates = embedded.coordinates
87
+ ```
88
+
89
+ By default, `ExecutionOptions()` uses all available GPUs. Set `ExecutionOptions(num_gpus=4)` when you want to cap the sharding explicitly.
90
+
91
+ Use `Pipeline(...)` for manifest-driven batch processing when you want artifacts written to disk instead of only in-memory outputs:
92
+
93
+ ```python
94
+ from slide2vec import ExecutionOptions, Pipeline
95
+
96
+ pipeline = Pipeline(
97
+ model=model,
98
+ preprocessing=preprocessing,
99
+ execution=ExecutionOptions(output_dir="outputs/demo"),
100
+ )
101
+ result = pipeline.run(manifest_path="/path/to/slides.csv")
102
+ ```
103
+
104
+ ### Input Manifest
105
+
106
+ Manifest-driven runs use the schema below. `mask_path` and `spacing_at_level_0` are optional.
107
+
108
+ ```csv
109
+ sample_id,image_path,mask_path,spacing_at_level_0
110
+ slide-1,/path/to/slide-1.svs,/path/to/mask-1.png,0.25
111
+ slide-2,/path/to/slide-2.svs,,
112
+ ...
113
+ ```
114
+
115
+ Use `spacing_at_level_0` when the slide file reports a missing or incorrect level-0 spacing and you want to override it.
116
+
117
+
118
+ ### Outputs
119
+
120
+ The package writes explicit artifact directories:
121
+
122
+ - `tile_embeddings/<sample_id>.pt` or `.npz`
123
+ - `tile_embeddings/<sample_id>.meta.json`
124
+ - `slide_embeddings/<sample_id>.pt` or `.npz`
125
+ - `slide_embeddings/<sample_id>.meta.json`
126
+ - optional `slide_latents/<sample_id>.pt` or `.npz`
127
+
128
+ `.pt` remains the default format. `.npz` is available through `ExecutionOptions(output_format="npz")`.
129
+
130
+ ### Supported Models
131
+
132
+ `slide2vec` currently ships preset configs for 10 tile-level models and 3 slide-level models.
133
+ For the full catalog and preset names, see [`docs/models.md`](docs/models.md).
134
+
135
+ ## CLI
136
+
137
+ The CLI is a thin wrapper over the package API.
138
+ Bundled configs live under `slide2vec/configs/preprocessing/` and `slide2vec/configs/models/`.
139
+
140
+ ```shell
141
+ python -m slide2vec --config-file /path/to/config.yaml
142
+ ```
143
+
144
+ By default, manifest-driven CLI runs use all available GPUs. Set `speed.num_gpus=4` when you want to cap the sharding explicitly.
145
+
146
+ New to the CLI or doing batch runs to disk? Start with [`docs/cli.md`](docs/cli.md) for the config-driven workflow, overrides, and common run patterns.
147
+
148
+ ## Docker
149
+
150
+ [![Docker Version](https://img.shields.io/docker/v/waticlems/slide2vec?sort=semver&label=docker&logo=docker&color=2496ED)](https://hub.docker.com/r/waticlems/slide2vec)
151
+
152
+ Docker remains available when you prefer a containerized runtime:
153
+
154
+ ```shell
155
+ docker pull waticlems/slide2vec:latest
156
+ docker run --rm -it \
157
+ -v /path/to/your/data:/data \
158
+ -e HF_TOKEN=<your-huggingface-api-token> \
159
+ waticlems/slide2vec:latest
160
+ ```
161
+
162
+ ## Documentation
163
+
164
+ - [`docs/cli.md`](docs/cli.md) for the config-driven CLI guide
165
+ - [`docs/python-api.md`](docs/python-api.md) for the detailed API reference
166
+ - [`docs/models.md`](docs/models.md) for the full supported-model catalog
@@ -0,0 +1,110 @@
1
+ # slide2vec
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/slide2vec?label=pypi&logo=pypi&color=3776AB)](https://pypi.org/project/slide2vec/)
4
+
5
+ `slide2vec` is a Python package for efficient encoding of whole-slide images using publicly available foundation models. It builds on [`hs2p`](https://pypi.org/project/hs2p/) for fast preprocessing and exposes a focused surface around `Model`, `Pipeline`, and `ExecutionOptions`.
6
+
7
+ ## Installation
8
+
9
+ ```shell
10
+ pip install slide2vec
11
+ ```
12
+
13
+ ## Python API
14
+
15
+ ```python
16
+ from slide2vec import Model, PreprocessingConfig
17
+
18
+ model = Model.from_pretrained("virchow2", level="region")
19
+ preprocessing = PreprocessingConfig(
20
+ target_spacing_um=0.5,
21
+ target_tile_size_px=224,
22
+ tissue_threshold=0.1,
23
+ )
24
+ embedded = model.embed_slide(
25
+ "/path/to/slide.svs",
26
+ preprocessing=preprocessing,
27
+ )
28
+
29
+ tile_embeddings = embedded.tile_embeddings
30
+ coordinates = embedded.coordinates
31
+ ```
32
+
33
+ By default, `ExecutionOptions()` uses all available GPUs. Set `ExecutionOptions(num_gpus=4)` when you want to cap the sharding explicitly.
34
+
35
+ Use `Pipeline(...)` for manifest-driven batch processing when you want artifacts written to disk instead of only in-memory outputs:
36
+
37
+ ```python
38
+ from slide2vec import ExecutionOptions, Pipeline
39
+
40
+ pipeline = Pipeline(
41
+ model=model,
42
+ preprocessing=preprocessing,
43
+ execution=ExecutionOptions(output_dir="outputs/demo"),
44
+ )
45
+ result = pipeline.run(manifest_path="/path/to/slides.csv")
46
+ ```
47
+
48
+ ### Input Manifest
49
+
50
+ Manifest-driven runs use the schema below. `mask_path` and `spacing_at_level_0` are optional.
51
+
52
+ ```csv
53
+ sample_id,image_path,mask_path,spacing_at_level_0
54
+ slide-1,/path/to/slide-1.svs,/path/to/mask-1.png,0.25
55
+ slide-2,/path/to/slide-2.svs,,
56
+ ...
57
+ ```
58
+
59
+ Use `spacing_at_level_0` when the slide file reports a missing or incorrect level-0 spacing and you want to override it.
60
+
61
+
62
+ ### Outputs
63
+
64
+ The package writes explicit artifact directories:
65
+
66
+ - `tile_embeddings/<sample_id>.pt` or `.npz`
67
+ - `tile_embeddings/<sample_id>.meta.json`
68
+ - `slide_embeddings/<sample_id>.pt` or `.npz`
69
+ - `slide_embeddings/<sample_id>.meta.json`
70
+ - optional `slide_latents/<sample_id>.pt` or `.npz`
71
+
72
+ `.pt` remains the default format. `.npz` is available through `ExecutionOptions(output_format="npz")`.
73
+
74
+ ### Supported Models
75
+
76
+ `slide2vec` currently ships preset configs for 10 tile-level models and 3 slide-level models.
77
+ For the full catalog and preset names, see [`docs/models.md`](docs/models.md).
78
+
79
+ ## CLI
80
+
81
+ The CLI is a thin wrapper over the package API.
82
+ Bundled configs live under `slide2vec/configs/preprocessing/` and `slide2vec/configs/models/`.
83
+
84
+ ```shell
85
+ python -m slide2vec --config-file /path/to/config.yaml
86
+ ```
87
+
88
+ By default, manifest-driven CLI runs use all available GPUs. Set `speed.num_gpus=4` when you want to cap the sharding explicitly.
89
+
90
+ New to the CLI or doing batch runs to disk? Start with [`docs/cli.md`](docs/cli.md) for the config-driven workflow, overrides, and common run patterns.
91
+
92
+ ## Docker
93
+
94
+ [![Docker Version](https://img.shields.io/docker/v/waticlems/slide2vec?sort=semver&label=docker&logo=docker&color=2496ED)](https://hub.docker.com/r/waticlems/slide2vec)
95
+
96
+ Docker remains available when you prefer a containerized runtime:
97
+
98
+ ```shell
99
+ docker pull waticlems/slide2vec:latest
100
+ docker run --rm -it \
101
+ -v /path/to/your/data:/data \
102
+ -e HF_TOKEN=<your-huggingface-api-token> \
103
+ waticlems/slide2vec:latest
104
+ ```
105
+
106
+ ## Documentation
107
+
108
+ - [`docs/cli.md`](docs/cli.md) for the config-driven CLI guide
109
+ - [`docs/python-api.md`](docs/python-api.md) for the detailed API reference
110
+ - [`docs/models.md`](docs/models.md) for the full supported-model catalog
@@ -23,7 +23,7 @@ warn_unused_configs = true
23
23
  no_implicit_reexport = true
24
24
 
25
25
  [tool.bumpver]
26
- current_version = "2.0.1"
26
+ current_version = "3.0.0"
27
27
  version_pattern = "MAJOR.MINOR.PATCH"
28
28
  commit = false # We do version bumping in CI, not as a commit
29
29
  tag = false # Git tag already exists — we don't auto-tag
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = slide2vec
3
- version = 2.0.1
3
+ version = 3.0.0
4
4
  description = Embedding of whole slide images with Foundation Models
5
5
  author = Clément Grisi
6
6
  platforms = unix, linux, osx, cygwin, win32
@@ -16,17 +16,18 @@ classifiers =
16
16
  packages =
17
17
  slide2vec
18
18
  install_requires =
19
+ hs2p>=2.0,<3
19
20
  omegaconf
21
+ h5py
20
22
  huggingface-hub
21
23
  numpy<2
22
24
  pandas
23
25
  pillow
26
+ rich
24
27
  tqdm
25
- numba
26
28
  torchvision
27
- opencv-python
28
- matplotlib
29
29
  wholeslidedata<0.0.16
30
+ matplotlib
30
31
  timm
31
32
  torch
32
33
  transformers
@@ -35,6 +36,7 @@ install_requires =
35
36
  einops
36
37
  einops-exts
37
38
  xformers
39
+ wandb
38
40
  python_requires = >=3.10
39
41
  zip_safe = no
40
42
  include_package_data = True
@@ -49,6 +51,11 @@ testing =
49
51
 
50
52
  [options.package_data]
51
53
  slide2vec = py.typed
54
+ slide2vec.configs = *.yaml, models/*.yaml, preprocessing/*.yaml
55
+
56
+ [options.entry_points]
57
+ console_scripts =
58
+ slide2vec = slide2vec.cli:main
52
59
 
53
60
  [flake8]
54
61
  max-line-length = 160
@@ -0,0 +1,17 @@
1
+ from slide2vec.api import EmbeddedSlide, ExecutionOptions, Model, Pipeline, PreprocessingConfig, RunResult
2
+ from slide2vec.artifacts import SlideEmbeddingArtifact, TileEmbeddingArtifact
3
+
4
+
5
+ __version__ = "3.0.0"
6
+
7
+ __all__ = [
8
+ "Model",
9
+ "Pipeline",
10
+ "PreprocessingConfig",
11
+ "ExecutionOptions",
12
+ "RunResult",
13
+ "EmbeddedSlide",
14
+ "SlideEmbeddingArtifact",
15
+ "TileEmbeddingArtifact",
16
+ "__version__",
17
+ ]
@@ -0,0 +1,5 @@
1
+ from slide2vec.cli import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ main()