slide2vec 6.2.0__tar.gz → 6.3.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 (182) hide show
  1. {slide2vec-6.2.0 → slide2vec-6.3.0}/PKG-INFO +3 -3
  2. {slide2vec-6.2.0 → slide2vec-6.3.0}/pyproject.toml +4 -4
  3. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/__init__.py +1 -1
  4. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/api.py +20 -8
  5. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/artifacts.py +7 -5
  6. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/cli.py +1 -2
  7. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/configs/default.yaml +1 -1
  8. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/distributed/dense_worker.py +2 -0
  9. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/distributed/direct_embed_worker.py +6 -0
  10. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/distributed/image_worker.py +2 -0
  11. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/base.py +27 -0
  12. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/gigapath.py +2 -1
  13. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/isight.py +2 -6
  14. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/phikon.py +2 -7
  15. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/prism.py +15 -2
  16. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/registry.py +14 -0
  17. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/inference.py +54 -17
  18. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/artifacts_collect.py +15 -5
  19. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/dense_image_recipe.py +15 -4
  20. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/dense_image_shard.py +18 -10
  21. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/dense_image_stage.py +15 -5
  22. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/dense_shard.py +45 -18
  23. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/dense_stage.py +34 -9
  24. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/distributed_stage.py +5 -0
  25. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/embedding.py +16 -1
  26. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/embedding_persist.py +16 -1
  27. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/embedding_pipeline.py +15 -3
  28. slide2vec-6.3.0/slide2vec/runtime/feature_identity.py +271 -0
  29. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/image_shard.py +11 -2
  30. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/image_stage.py +51 -11
  31. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/model_settings.py +5 -0
  32. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/patient_pipeline.py +29 -2
  33. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/persist_callbacks.py +37 -61
  34. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/persistence.py +2 -1
  35. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/process_list.py +17 -10
  36. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/serialization.py +2 -0
  37. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/slide_encode.py +35 -8
  38. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/tiling_pipeline.py +5 -2
  39. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/utils/config.py +0 -17
  40. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/utils/tiling_io.py +3 -2
  41. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec.egg-info/PKG-INFO +3 -3
  42. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec.egg-info/SOURCES.txt +5 -0
  43. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec.egg-info/requires.txt +2 -2
  44. slide2vec-6.3.0/tests/test_cli_noninteractive.py +77 -0
  45. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_image_resume.py +72 -6
  46. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_image_shard.py +83 -0
  47. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_image_stage.py +32 -4
  48. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_shard.py +175 -13
  49. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_stage.py +118 -4
  50. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_worker.py +1 -0
  51. slide2vec-6.3.0/tests/test_feature_identity.py +904 -0
  52. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_gigapath.py +39 -3
  53. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_hs2p5_integration.py +83 -0
  54. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_image_shard.py +21 -12
  55. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_image_stage.py +114 -3
  56. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_output_consistency.py +21 -0
  57. slide2vec-6.3.0/tests/test_patient_annotation_sampling.py +187 -0
  58. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_pooled_geometry.py +3 -0
  59. slide2vec-6.3.0/tests/test_prism.py +93 -0
  60. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_process_list_performance.py +19 -0
  61. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_regression_core.py +29 -19
  62. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_regression_inference.py +39 -23
  63. slide2vec-6.3.0/tests/test_slide_latents.py +332 -0
  64. slide2vec-6.2.0/tests/test_prism.py +0 -52
  65. {slide2vec-6.2.0 → slide2vec-6.3.0}/LICENSE +0 -0
  66. {slide2vec-6.2.0 → slide2vec-6.3.0}/README.md +0 -0
  67. {slide2vec-6.2.0 → slide2vec-6.3.0}/setup.cfg +0 -0
  68. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/__main__.py +0 -0
  69. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/_cufile.py +0 -0
  70. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/configs/__init__.py +0 -0
  71. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/configs/resources.py +0 -0
  72. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/cufile.json +0 -0
  73. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/data/__init__.py +0 -0
  74. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/data/dataset.py +0 -0
  75. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/data/tile_reader.py +0 -0
  76. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/data/tile_store.py +0 -0
  77. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/distributed/__init__.py +0 -0
  78. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/distributed/dense_image_worker.py +0 -0
  79. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/distributed/pin_gpu.py +0 -0
  80. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/distributed/pipeline_worker.py +0 -0
  81. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/distributed/worker_entry.py +0 -0
  82. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/__init__.py +0 -0
  83. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/__init__.py +0 -0
  84. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/conch.py +0 -0
  85. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/dinov2.py +0 -0
  86. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/dinov3.py +0 -0
  87. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/genbio.py +0 -0
  88. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/gpfm.py +0 -0
  89. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/hibou.py +0 -0
  90. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/hoptimus.py +0 -0
  91. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/lunit.py +0 -0
  92. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/mettle.py +0 -0
  93. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/midnight.py +0 -0
  94. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/moozy/__init__.py +0 -0
  95. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/moozy/blocks.py +0 -0
  96. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/moozy/case.py +0 -0
  97. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/moozy/loading.py +0 -0
  98. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/moozy/slide.py +0 -0
  99. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/moozy/types.py +0 -0
  100. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/mstar.py +0 -0
  101. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/musk.py +0 -0
  102. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/prism2.py +0 -0
  103. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/prost40m.py +0 -0
  104. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/rudolfv2.py +0 -0
  105. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/titan.py +0 -0
  106. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/uni.py +0 -0
  107. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/virchow.py +0 -0
  108. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/models/waiv.py +0 -0
  109. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/encoders/validation.py +0 -0
  110. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/progress.py +0 -0
  111. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/__init__.py +0 -0
  112. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/batching.py +0 -0
  113. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/cpu_budget.py +0 -0
  114. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/dense_encode.py +0 -0
  115. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/dense_encoder_input.py +0 -0
  116. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/dense_image_reading.py +0 -0
  117. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/dense_regions.py +0 -0
  118. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/dense_sliding.py +0 -0
  119. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/distributed.py +0 -0
  120. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/effective_encoder_input.py +0 -0
  121. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/encoder_input_contract.py +0 -0
  122. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/hierarchical.py +0 -0
  123. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/image_specs.py +0 -0
  124. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/manifest.py +0 -0
  125. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/pooled_encoder_input.py +0 -0
  126. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/preprocessing.py +0 -0
  127. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/progress_bridge.py +0 -0
  128. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/registry.py +0 -0
  129. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/sharding.py +0 -0
  130. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/tiling.py +0 -0
  131. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/types.py +0 -0
  132. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/runtime/worker_io.py +0 -0
  133. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/utils/__init__.py +0 -0
  134. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/utils/coordinates.py +0 -0
  135. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/utils/log_utils.py +0 -0
  136. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec/utils/utils.py +0 -0
  137. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec.egg-info/dependency_links.txt +0 -0
  138. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec.egg-info/entry_points.txt +0 -0
  139. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec.egg-info/not-zip-safe +0 -0
  140. {slide2vec-6.2.0 → slide2vec-6.3.0}/slide2vec.egg-info/top_level.txt +0 -0
  141. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_attention_extraction.py +0 -0
  142. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_benchmark_tooling.py +0 -0
  143. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_cufile_compat_mode.py +0 -0
  144. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_encode_kit.py +0 -0
  145. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_encoder_input.py +0 -0
  146. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_extraction.py +0 -0
  147. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_image_reading.py +0 -0
  148. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_regions.py +0 -0
  149. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_sliding.py +0 -0
  150. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dense_source_spacing.py +0 -0
  151. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dinov2_natimage.py +0 -0
  152. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_dinov3_natimage.py +0 -0
  153. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_encoder_capabilities.py +0 -0
  154. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_encoder_input_contract.py +0 -0
  155. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_encoder_plugins.py +0 -0
  156. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_encoder_preprocessing.py +0 -0
  157. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_encoder_provider_failures.py +0 -0
  158. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_encoder_registry.py +0 -0
  159. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_gpfm_genbio_heavy.py +0 -0
  160. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_hs2p_package_cutover.py +0 -0
  161. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_inference_benchmark.py +0 -0
  162. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_isight.py +0 -0
  163. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_load_model_hf_auth.py +0 -0
  164. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_mascaret.py +0 -0
  165. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_mettle.py +0 -0
  166. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_on_slide_persisted.py +0 -0
  167. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_patch_size_metadata.py +0 -0
  168. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_patient_manifest.py +0 -0
  169. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_phaet.py +0 -0
  170. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_pooled_encoder_input.py +0 -0
  171. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_prism2.py +0 -0
  172. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_progress.py +0 -0
  173. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_regression_models.py +0 -0
  174. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_rudolfv2.py +0 -0
  175. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_runtime_batching.py +0 -0
  176. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_sharding.py +0 -0
  177. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_slide_coordinate_preparation.py +0 -0
  178. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_soma_migration.py +0 -0
  179. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_tile_store.py +0 -0
  180. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_tiling_pipeline.py +0 -0
  181. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_titan.py +0 -0
  182. {slide2vec-6.2.0 → slide2vec-6.3.0}/tests/test_worker_gpu_pinning.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: slide2vec
3
- Version: 6.2.0
3
+ Version: 6.3.0
4
4
  Summary: Embedding of whole slide images with Foundation Models
5
5
  Author-email: Clément Grisi <clement.grisi@radboudumc.nl>
6
6
  License-Expression: Apache-2.0
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.13
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: hs2p[asap,cucim,openslide,sam2,vips]>=5.0.2
18
+ Requires-Dist: hs2p[asap,cucim,openslide,sam2,tifffile,vips]>=5.1.0
19
19
  Requires-Dist: omegaconf
20
20
  Requires-Dist: matplotlib
21
21
  Requires-Dist: numpy<2
@@ -75,7 +75,7 @@ Requires-Dist: numpy<2; extra == "fm"
75
75
  Requires-Dist: pandas; extra == "fm"
76
76
  Requires-Dist: pillow; extra == "fm"
77
77
  Requires-Dist: rich; extra == "fm"
78
- Requires-Dist: hs2p[asap,cucim,openslide,sam2,vips]>=5.0.2; extra == "fm"
78
+ Requires-Dist: hs2p[asap,cucim,openslide,sam2,tifffile,vips]>=5.1.0; extra == "fm"
79
79
  Requires-Dist: wandb; extra == "fm"
80
80
  Requires-Dist: torch<2.8,>=2.3; extra == "fm"
81
81
  Requires-Dist: torchvision>=0.18.0; extra == "fm"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "slide2vec"
7
- version = "6.2.0"
7
+ version = "6.3.0"
8
8
  description = "Embedding of whole slide images with Foundation Models"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -21,7 +21,7 @@ classifiers = [
21
21
  "Programming Language :: Python :: 3.13",
22
22
  ]
23
23
  dependencies = [
24
- "hs2p[asap,cucim,openslide,sam2,vips]>=5.0.2",
24
+ "hs2p[asap,cucim,openslide,sam2,tifffile,vips]>=5.1.0",
25
25
  "omegaconf",
26
26
  "matplotlib",
27
27
  "numpy<2",
@@ -100,7 +100,7 @@ fm = [
100
100
  "pandas",
101
101
  "pillow",
102
102
  "rich",
103
- "hs2p[asap,cucim,openslide,sam2,vips]>=5.0.2",
103
+ "hs2p[asap,cucim,openslide,sam2,tifffile,vips]>=5.1.0",
104
104
  "wandb",
105
105
  "torch>=2.3,<2.8",
106
106
  "torchvision>=0.18.0",
@@ -180,7 +180,7 @@ no_implicit_reexport = true
180
180
  max-line-length = 160
181
181
 
182
182
  [tool.bumpver]
183
- current_version = "6.2.0"
183
+ current_version = "6.3.0"
184
184
  version_pattern = "MAJOR.MINOR.PATCH"
185
185
  commit = false
186
186
  tag = false
@@ -31,7 +31,7 @@ from slide2vec.encoders import (
31
31
  )
32
32
 
33
33
 
34
- __version__ = "6.2.0"
34
+ __version__ = "6.3.0"
35
35
 
36
36
  __all__ = [
37
37
  "Model",
@@ -153,8 +153,10 @@ class PreprocessingConfig:
153
153
  #: explicitly (e.g. ``"openslide"``) when a precomputed tissue or annotation mask needs
154
154
  #: a different decoder than its slide — hs2p no longer silently falls back to another
155
155
  #: reader, so a mask the slide backend cannot decode fails unless overridden here.
156
- #: Accepts the same values as :attr:`backend` plus ``"pil"`` for PNG/JPEG masks;
157
- #: ``"auto"`` selects PIL for these masks. Ignored for slides with no source mask.
156
+ #: Accepts the same values as :attr:`backend` plus ``"pil"`` for PNG/JPEG masks and
157
+ #: ``"tifffile"`` for lossless label reads; ``"auto"`` selects PIL for PNG/JPEG masks
158
+ #: and ``"tifffile"`` for TIFF masks whose samples are not 8-bit unsigned.
159
+ #: Ignored for slides with no source mask.
158
160
  #: Masks need no spacing metadata, but must align to the slide's field of view and
159
161
  #: contain only declared label IDs. See :doc:`preprocessing` for hs2p 5 validation.
160
162
  mask_backend: str = "auto"
@@ -179,6 +181,10 @@ class PreprocessingConfig:
179
181
  read_tiles_from: Path | None = None
180
182
  #: Read and decode tiles on demand rather than pre-loading into memory.
181
183
  on_the_fly: bool = True
184
+ #: Write the extracted tiles to ``tiles/<sample_id>.tiles.tar`` next to the coordinate
185
+ #: artifacts. Tiles are also written when ``on_the_fly`` is ``False`` and
186
+ #: ``read_tiles_from`` is unset, because embedding then reads them from the archive.
187
+ save_tiles: bool = False
182
188
  #: Decode tiles on the GPU via CuCIM / nvImageCodec when ``True``.
183
189
  gpu_decode: bool = False
184
190
  #: Dynamically adjust batch size based on tile count.
@@ -285,6 +291,7 @@ class PreprocessingConfig:
285
291
  Path(read_tiles_from) if read_tiles_from else None
286
292
  ),
287
293
  on_the_fly=on_the_fly,
294
+ save_tiles=bool(cfg.save_tiles),
288
295
  gpu_decode=gpu_decode,
289
296
  adaptive_batching=adaptive_batching,
290
297
  use_supertiles=bool(tiling.use_supertiles),
@@ -336,7 +343,8 @@ class ExecutionOptions:
336
343
  save_tile_embeddings: bool = False
337
344
  #: Persist slide embeddings to disk when running a patient-level model.
338
345
  save_slide_embeddings: bool = False
339
- #: Persist encoder latent representations when available.
346
+ #: Return and persist the slide encoder's latent representations (PRISM). Encoders
347
+ #: without latents ignore it.
340
348
  save_latents: bool = False
341
349
 
342
350
  @classmethod
@@ -622,10 +630,13 @@ class EmbeddedSlide:
622
630
  mask_preview_path: Path | None = None
623
631
  #: Path to the tiling preview image, if generated.
624
632
  tiling_preview_path: Path | None = None
625
- #: Encoder latent representations when available; ``None`` otherwise.
633
+ #: Slide encoder latent representations when ``ExecutionOptions.save_latents`` is set
634
+ #: and the encoder has them (PRISM: shape ``(512, 1280)``); ``None`` otherwise.
626
635
  latents: Any | None = None
627
636
  #: Factual square tensor side length immediately before tile encoding.
628
637
  encoder_input_size_px: int | None = None
638
+ #: Record of the image transform applied before tile encoding (JSON data).
639
+ transform: dict[str, Any] | None = None
629
640
 
630
641
 
631
642
  class Model:
@@ -892,8 +903,8 @@ class Model:
892
903
  dense transform, and written to ``dense_embeddings/[<class>/]<sample_id>/<x>_<y>.pt``
893
904
  plus a geometry sidecar. The run splits its ROIs across all visible GPUs
894
905
  (``execution.num_gpus``); ``num_gpus=1`` encodes fully in-process. Resume is
895
- automatic — only ROIs whose sidecar has the same source-spacing declaration and
896
- resolved hs2p read plan are skipped. Returns one
906
+ automatic — only ROIs whose sidecar has the same source-spacing declaration,
907
+ resolved hs2p read plan and feature identity are skipped. Returns one
897
908
  :class:`~slide2vec.artifacts.DenseRegionArtifact` per input ROI.
898
909
 
899
910
  The effective encoder input — the padded ROI for a whole-tile run, one
@@ -971,8 +982,9 @@ class Model:
971
982
  to ``image_embeddings/<sample_id>.pt`` plus a provenance sidecar. The run splits its
972
983
  images across all visible GPUs (``execution.num_gpus``); ``num_gpus=1`` encodes
973
984
  fully in-process. Resume is automatic — images whose sidecar already exists are
974
- skipped. Returns one :class:`~slide2vec.artifacts.ImageEmbeddingArtifact` per input
975
- image, in input order.
985
+ skipped, and a sidecar that records a different feature identity raises. Returns
986
+ one :class:`~slide2vec.artifacts.ImageEmbeddingArtifact` per input image, in input
987
+ order.
976
988
 
977
989
  Unlike the pooled and dense paths there is no geometry to declare: the images are
978
990
  heterogeneously sized (2048x1536 beside 96x96) and were never requested, so the
@@ -316,13 +316,15 @@ def _write_dense_grid(
316
316
  ) -> np.ndarray:
317
317
  """Publish one dense grid: payload atomically, then the sidecar. Returns the array.
318
318
 
319
- The single write order every dense artifact follows (D6), whatever named it: payload to
320
- a temp file in the destination directory → ``os.replace`` into place (atomic on the same
321
- filesystem) → then the ``.meta.json`` sidecar. A payload present without its sidecar
322
- therefore unambiguously means an incomplete unit, and resume treats the sidecar as the
323
- done-marker.
319
+ The single write order every dense artifact follows (D6), whatever named it: remove any
320
+ existing sidecar → payload to a temp file in the destination directory → ``os.replace``
321
+ into place (atomic on the same filesystem) → then the ``.meta.json`` sidecar. A payload
322
+ present without its sidecar therefore unambiguously means an incomplete unit, and resume
323
+ treats the sidecar as the done-marker. Removing the old sidecar first keeps a rewrite
324
+ interrupted between the two writes from pairing it with the new payload.
324
325
  """
325
326
  grid_array = _ensure_array(grid)
327
+ metadata_path.unlink(missing_ok=True)
326
328
  write_atomically(payload_path, lambda tmp_path: torch.save(_ensure_tensor(grid), tmp_path))
327
329
  _write_metadata(metadata_path, metadata)
328
330
  return grid_array
@@ -2,7 +2,7 @@ import argparse
2
2
 
3
3
  from slide2vec.api import ExecutionOptions, Model, Pipeline, PreprocessingConfig
4
4
  from slide2vec.progress import activate_progress_reporter, create_cli_progress_reporter
5
- from slide2vec.utils.config import setup, hf_login
5
+ from slide2vec.utils.config import setup
6
6
 
7
7
 
8
8
  def get_args_parser(add_help: bool = True):
@@ -24,7 +24,6 @@ def parse_args(argv=None):
24
24
 
25
25
  def build_model_and_pipeline(args):
26
26
  cfg, _cfg_path = setup(args)
27
- hf_login()
28
27
  model = Model.from_preset(
29
28
  cfg.model.name,
30
29
  output_variant=cfg.model.output_variant,
@@ -26,7 +26,7 @@ tiling:
26
26
  read_coordinates_from: # path to an existing directory containing pre-extracted `.coordinates.npz` / `.coordinates.meta.json` artifacts to reuse instead of starting tiling from scratch
27
27
  read_tiles_from: # path to an existing directory containing pre-extracted `.tiles.tar` tile stores to reuse instead of starting tiling from scratch
28
28
  backend: "auto" # backend to use for slide reading; "auto" tries cucim -> vips -> openslide -> asap. Pin a backend for stable decoder selection across upgrades.
29
- mask_backend: "auto" # backend for reading source masks (precomputed tissue / annotation), resolved independently from the mask path; "auto" probes openability like `backend`. Set explicitly (e.g. "openslide") when a mask needs a different decoder than its slide — hs2p (>=4.3.0) no longer silently falls back
29
+ mask_backend: "auto" # backend for reading source masks (precomputed tissue / annotation), resolved independently from the mask path; "auto" probes openability like `backend`. Set explicitly (e.g. "openslide") when a mask needs a different decoder than its slide — hs2p never silently falls back. "auto" selects "tifffile" for TIFF masks whose samples are not 8-bit unsigned (e.g. 16-bit labels)
30
30
  independent_sampling: true # selection strategy when annotation sampling is active. true: sample each class independently against its own binary mask (independent selection); false: sample once over the union of active classes, then post-filter per class by coverage (joint selection). Ignored when the masks vocabulary is left at the tissue-only default.
31
31
  masks:
32
32
  # Annotation-mask vocabulary forwarded to hs2p's sampling resolver. The shipped default
@@ -27,6 +27,7 @@ def get_args_parser(add_help: bool = True):
27
27
  def main(argv=None) -> int:
28
28
  from slide2vec.progress import emit_progress
29
29
  from slide2vec.runtime.dense_shard import run_dense_shard
30
+ from slide2vec.runtime.feature_identity import dense_feature_identity
30
31
  from slide2vec.runtime.dense_stage import (
31
32
  region_specs_from_request,
32
33
  resolve_output_torch_dtype,
@@ -68,6 +69,7 @@ def main(argv=None) -> int:
68
69
  dense=dense,
69
70
  batch_size=int(execution.batch_size),
70
71
  device=loaded.device,
72
+ identity=dense_feature_identity(model, dense=dense, execution=execution),
71
73
  precision=execution.precision,
72
74
  output_dtype=resolve_output_torch_dtype(execution),
73
75
  num_workers=execution.resolved_num_workers_per_gpu(),
@@ -55,6 +55,7 @@ def main(argv=None) -> int:
55
55
  work_unit_shard_stem,
56
56
  )
57
57
  from slide2vec.runtime.embedding import tiling_result_annotation
58
+ from slide2vec.runtime.feature_identity import transform_record
58
59
 
59
60
  load_successful_tiled_slides_fn = getattr(inference, "load_successful_tiled_slides", None)
60
61
  if not callable(load_successful_tiled_slides_fn):
@@ -84,6 +85,8 @@ def main(argv=None) -> int:
84
85
  shard_stem = work_unit_shard_stem(*decode_work_unit(work_unit))
85
86
  slide, tiling_result = paired_by_unit[work_unit]
86
87
  loaded = model._load_backend()
88
+ # The parent writes the sidecar without loading the encoder; hand it the record.
89
+ transform = transform_record(getattr(loaded, "transforms", None))
87
90
  if is_hierarchical_preprocessing(preprocessing):
88
91
  geometry = resolve_hierarchical_geometry(preprocessing, tiling_result)
89
92
  index = build_hierarchical_index(
@@ -113,6 +116,7 @@ def main(argv=None) -> int:
113
116
  "flat_index": torch.as_tensor(shard_indices, dtype=torch.long),
114
117
  "tile_embeddings": tile_embeddings.detach().cpu() if torch.is_tensor(tile_embeddings) else torch.as_tensor(tile_embeddings),
115
118
  "encoder_input_size_px": getattr(loaded, "encoder_input_size_px", None),
119
+ "transform": transform,
116
120
  }
117
121
  torch.save(payload, coordination_dir / f"{shard_stem}.hier.rank{global_rank}.pt")
118
122
  else:
@@ -140,6 +144,7 @@ def main(argv=None) -> int:
140
144
  "tile_index": torch.as_tensor(tile_indices, dtype=torch.long),
141
145
  "tile_embeddings": tile_embeddings.detach().cpu() if torch.is_tensor(tile_embeddings) else torch.as_tensor(tile_embeddings),
142
146
  "encoder_input_size_px": getattr(loaded, "encoder_input_size_px", None),
147
+ "transform": transform,
143
148
  }
144
149
  torch.save(payload, coordination_dir / f"{shard_stem}.tiles.rank{global_rank}.pt")
145
150
  return 0
@@ -156,6 +161,7 @@ def main(argv=None) -> int:
156
161
  "slide_embedding": _to_cpu_payload(embedded_slide.slide_embedding),
157
162
  "latents": _to_cpu_payload(embedded_slide.latents),
158
163
  "encoder_input_size_px": embedded_slide.encoder_input_size_px,
164
+ "transform": embedded_slide.transform,
159
165
  }
160
166
  # Stem by (sample_id, annotation) so two classes of one slide never overwrite each
161
167
  # other; flat units keep the bare-sample_id filename for backward compatibility.
@@ -26,6 +26,7 @@ def get_args_parser(add_help: bool = True):
26
26
 
27
27
  def main(argv=None) -> int:
28
28
  from slide2vec.progress import emit_progress
29
+ from slide2vec.runtime.feature_identity import pooled_feature_identity
29
30
  from slide2vec.runtime.image_shard import run_image_shard
30
31
  from slide2vec.runtime.image_specs import image_specs_from_request
31
32
  from slide2vec.runtime.model_settings import resolve_output_precision
@@ -60,6 +61,7 @@ def main(argv=None) -> int:
60
61
  out_dir=output_dir,
61
62
  batch_size=int(execution.batch_size),
62
63
  output_precision=resolve_output_precision(execution.output_dtype, execution.precision),
64
+ identity=pooled_feature_identity(model, execution=execution),
63
65
  output_format=execution.output_format,
64
66
  precision=execution.precision,
65
67
  num_workers=execution.resolved_image_num_workers_per_gpu(),
@@ -390,6 +390,20 @@ def attentions_tuple_to_grids(
390
390
  return torch.cat(grids, dim=1)
391
391
 
392
392
 
393
+ class ProcessorTransform:
394
+ """Apply a Hugging Face processor to one image.
395
+
396
+ A class rather than a closure so the processor stays readable: the sidecar's
397
+ transform record is read from it.
398
+ """
399
+
400
+ def __init__(self, processor) -> None:
401
+ self.processor = processor
402
+
403
+ def __call__(self, image) -> Tensor:
404
+ return self.processor(images=image, return_tensors="pt")["pixel_values"].squeeze(0)
405
+
406
+
393
407
  class Encoder(ABC):
394
408
  """Shared lifecycle contract for all encoders."""
395
409
 
@@ -527,6 +541,19 @@ class SlideEncoder(Encoder):
527
541
  """Pool tile-level features into a single slide-level embedding."""
528
542
  ...
529
543
 
544
+ def encode_slide_with_latents(
545
+ self,
546
+ tile_features: Tensor,
547
+ coordinates: Tensor | None = None,
548
+ *,
549
+ tile_size_lv0: int | None = None,
550
+ ) -> tuple[Tensor, Tensor | None]:
551
+ """Return the slide embedding and the encoder's latent representations.
552
+
553
+ Encoders that have latents (PRISM) override this; the default returns ``None``.
554
+ """
555
+ return self.encode_slide(tile_features, coordinates, tile_size_lv0=tile_size_lv0), None
556
+
530
557
 
531
558
  class PatientEncoder(Encoder):
532
559
  """Base class for encoders that aggregate slide embeddings into patient embeddings."""
@@ -93,7 +93,8 @@ class GigaPathSlideEncoder(SlideEncoder):
93
93
  # create_model given an "hf_hub:" name force-downloads into ~/.cache/ on every
94
94
  # load, ignoring HF_HOME; a local path skips that download.
95
95
  checkpoint_path = _slide_checkpoint_path()
96
- self._model = create_model(checkpoint_path, "gigapath_slide_enc12l768d", 1536)
96
+ # create_model returns the module in training mode (dropout and drop-path active).
97
+ self._model = create_model(checkpoint_path, "gigapath_slide_enc12l768d", 1536).eval()
97
98
  self._device = preferred_default_device()
98
99
  self._output_variant = resolve_requested_output_variant(output_variant)
99
100
 
@@ -84,6 +84,7 @@ from torchvision.transforms import v2
84
84
  from transformers import AutoProcessor, CLIPConfig, CLIPModel
85
85
 
86
86
  from slide2vec.encoders.base import (
87
+ ProcessorTransform,
87
88
  TileEncoder,
88
89
  attentions_tuple_to_grids,
89
90
  hf_eager_attention,
@@ -190,12 +191,7 @@ class ISight(TileEncoder):
190
191
  bicubic resize to 336, a 336 center crop, and OpenAI CLIP
191
192
  mean/std — the resize and crop are no-ops on tiles already cut at 336.
192
193
  """
193
- processor = AutoProcessor.from_pretrained(_BASE_MODEL)
194
-
195
- def transform(image):
196
- return processor(images=image, return_tensors="pt")["pixel_values"].squeeze(0)
197
-
198
- return transform
194
+ return ProcessorTransform(AutoProcessor.from_pretrained(_BASE_MODEL))
199
195
 
200
196
  def get_normalization_transform(self) -> Callable:
201
197
  image_processor = AutoProcessor.from_pretrained(_BASE_MODEL).image_processor
@@ -10,6 +10,7 @@ from torch import Tensor
10
10
  from transformers import AutoImageProcessor, AutoModel
11
11
 
12
12
  from slide2vec.encoders.base import (
13
+ ProcessorTransform,
13
14
  TileEncoder,
14
15
  attentions_tuple_to_grids,
15
16
  hf_eager_attention,
@@ -33,13 +34,7 @@ class _PhikonBase(TileEncoder):
33
34
  self._output_variant = resolve_requested_output_variant(output_variant)
34
35
 
35
36
  def get_transform(self) -> Callable:
36
- processor = self._processor
37
-
38
- def _transform(img):
39
- inputs = processor(images=img, return_tensors="pt")
40
- return inputs["pixel_values"].squeeze(0)
41
-
42
- return _transform
37
+ return ProcessorTransform(self._processor)
43
38
 
44
39
  def get_normalization_transform(self) -> Callable:
45
40
  # Normalization only — no resize/crop.
@@ -44,9 +44,22 @@ class PrismSlideEncoder(SlideEncoder):
44
44
  *,
45
45
  tile_size_lv0: int | None = None,
46
46
  ) -> torch.Tensor:
47
+ return self._slide_representations(tile_features)["image_embedding"].squeeze(0)
48
+
49
+ def encode_slide_with_latents(
50
+ self,
51
+ tile_features: torch.Tensor,
52
+ coordinates: torch.Tensor | None = None,
53
+ *,
54
+ tile_size_lv0: int | None = None,
55
+ ) -> tuple[torch.Tensor, torch.Tensor]:
56
+ # image_latents: the Perceiver latents, [1, 512, 1280] for one slide.
57
+ reprs = self._slide_representations(tile_features)
58
+ return reprs["image_embedding"].squeeze(0), reprs["image_latents"].squeeze(0)
59
+
60
+ def _slide_representations(self, tile_features: torch.Tensor) -> dict[str, torch.Tensor]:
47
61
  if tile_features.ndim == 2:
48
62
  tile_features = tile_features.unsqueeze(0)
49
63
  # Stored feature precision can differ from PRISM's weights; CPU has no autocast.
50
64
  tile_features = tile_features.to(dtype=self._model.dtype)
51
- reprs = self._model.slide_representations(tile_features)
52
- return reprs["image_embedding"].squeeze(0)
65
+ return self._model.slide_representations(tile_features)
@@ -247,6 +247,20 @@ def _supports_attention(encoder_cls: type) -> bool:
247
247
  )
248
248
 
249
249
 
250
+ def supports_slide_latents(encoder_name: str) -> bool:
251
+ """Whether a registered encoder returns latents with its slide embedding.
252
+
253
+ Resolved from the class (an override of ``SlideEncoder.encode_slide_with_latents``),
254
+ so no model is constructed.
255
+ """
256
+ encoder_cls = encoder_registry.require(encoder_name)
257
+ return (
258
+ issubclass(encoder_cls, SlideEncoder)
259
+ and encoder_cls.encode_slide_with_latents
260
+ is not SlideEncoder.encode_slide_with_latents
261
+ )
262
+
263
+
250
264
  def _format_names(names: list[str]) -> str:
251
265
  if len(names) == 1:
252
266
  return names[0]
@@ -13,6 +13,7 @@ from slide2vec.runtime import (
13
13
  embedding,
14
14
  embedding_persist,
15
15
  embedding_pipeline,
16
+ feature_identity,
16
17
  hierarchical,
17
18
  manifest,
18
19
  patient_pipeline,
@@ -302,8 +303,7 @@ def embed_slides(
302
303
  zero_tile_pairs,
303
304
  model=model,
304
305
  preprocessing=preprocessing,
305
- output_dir=execution.output_dir,
306
- output_format=execution.output_format,
306
+ execution=execution,
307
307
  )
308
308
  emit_progress("embedding.started", slide_count=len(embeddable_slides))
309
309
  if execution.num_gpus > 1 and len(embeddable_slides) > 1:
@@ -433,6 +433,7 @@ def embed_patients(
433
433
  f"embed_patients() requires a patient-level model, but '{model.name}' "
434
434
  f"has level='{model.level}'. Use embed_slides() for slide-level models."
435
435
  )
436
+ patient_pipeline.reject_per_annotation_sampling(model, preprocessing)
436
437
  slide_records = [manifest.coerce_slide_spec(slide) for slide in slides]
437
438
  if not slide_records:
438
439
  raise ValueError("At least one slide is required")
@@ -611,6 +612,12 @@ def embed_tiles(
611
612
  # idempotent, so declaring in both places is intended.
612
613
  model._declare_encoder_input(resolved_preprocessing, emit_run_info=False)
613
614
  loaded = model._load_backend()
615
+ compatibility = feature_identity.pooled_feature_identity(
616
+ model,
617
+ execution=execution,
618
+ preprocessing=resolved_preprocessing,
619
+ transform=feature_identity.transform_record(getattr(loaded, "transforms", None)),
620
+ )
614
621
  hierarchical_mode = hierarchical.is_hierarchical_preprocessing(resolved_preprocessing)
615
622
  cpu_budget.log_on_the_fly_worker_override_once(
616
623
  resolved_preprocessing,
@@ -638,6 +645,7 @@ def embed_tiles(
638
645
  mask_path=slide.mask_path,
639
646
  backend=tiling.resolve_slide_backend(resolved_preprocessing.backend, tiling_result),
640
647
  preprocessing=resolved_preprocessing,
648
+ compatibility=compatibility,
641
649
  encoder_input_size_px=getattr(loaded, "encoder_input_size_px", None),
642
650
  ),
643
651
  annotation=embedding.tiling_result_annotation(tiling_result),
@@ -658,6 +666,7 @@ def embed_tiles(
658
666
  mask_path=slide.mask_path,
659
667
  tile_size_lv0=int(tiling_result.tile_size_lv0),
660
668
  backend=tiling.resolve_slide_backend(resolved_preprocessing.backend, tiling_result),
669
+ compatibility=compatibility,
661
670
  encoder_input_size_px=getattr(loaded, "encoder_input_size_px", None),
662
671
  )
663
672
  artifact = embedding.write_tile_embedding_artifact(
@@ -701,20 +710,43 @@ def aggregate_tiles(
701
710
  tile_features = load_array(artifact.path)
702
711
  if not torch.is_tensor(tile_features):
703
712
  tile_features = torch.as_tensor(tile_features)
704
- slide_embedding = slide_encode.encode_slide_from_tiles(
705
- loaded,
706
- tile_features,
707
- tiling_result,
708
- execution=execution,
709
- )
713
+ if execution.save_latents:
714
+ slide_embedding, latents = slide_encode.encode_slide_with_latents_from_tiles(
715
+ loaded,
716
+ tile_features,
717
+ tiling_result,
718
+ execution=execution,
719
+ )
720
+ else:
721
+ slide_embedding = slide_encode.encode_slide_from_tiles(
722
+ loaded,
723
+ tile_features,
724
+ tiling_result,
725
+ execution=execution,
726
+ )
727
+ latents = None
728
+ # Aggregation encodes no tile: the tile geometry and transform are the ones
729
+ # recorded with the tile artifact.
730
+ tile_identity = metadata.get("compatibility") or {}
731
+ compatibility = {
732
+ **feature_identity.pooled_feature_identity(model, execution=execution),
733
+ **{
734
+ field: tile_identity[field]
735
+ for field in ("requested_tile_size_px", "encoder_input_size_px", "transform")
736
+ if field in tile_identity
737
+ },
738
+ }
710
739
  slide_artifact = embedding.write_slide_embedding_artifact(
711
740
  artifact.sample_id,
712
741
  slide_embedding,
713
742
  execution=execution,
714
743
  metadata=embedding.build_slide_embedding_metadata(
715
- model, image_path=metadata["image_path"], tiling_result=tiling_result
744
+ model,
745
+ image_path=metadata["image_path"],
746
+ tiling_result=tiling_result,
747
+ compatibility=compatibility,
716
748
  ),
717
- latents=None,
749
+ latents=latents,
718
750
  )
719
751
  outputs.append(slide_artifact)
720
752
  return outputs
@@ -748,9 +780,11 @@ def run_pipeline(
748
780
  if not tiling_only and execution.num_gpus > 1:
749
781
  distributed_stage.validate_multi_gpu_execution(model, execution)
750
782
 
783
+ resolved_preprocessing = tiling_pipeline.resolve_model_preprocessing(model, preprocessing)
784
+ if model.level == "patient" and not tiling_only:
785
+ patient_pipeline.reject_per_annotation_sampling(model, resolved_preprocessing)
751
786
  output_dir = Path(execution.output_dir)
752
787
  output_dir.mkdir(parents=True, exist_ok=True)
753
- resolved_preprocessing = tiling_pipeline.resolve_model_preprocessing(model, preprocessing)
754
788
  distributed_stage.write_embedding_request(model, resolved_preprocessing, execution, output_dir)
755
789
  emit_progress(
756
790
  "run.started",
@@ -801,8 +835,7 @@ def run_pipeline(
801
835
  zero_tile_pairs,
802
836
  model=model,
803
837
  preprocessing=resolved_preprocessing,
804
- output_dir=output_dir,
805
- output_format=execution.output_format,
838
+ execution=execution,
806
839
  )
807
840
  emit_progress("embedding.started", slide_count=len(embeddable_slides))
808
841
 
@@ -877,9 +910,14 @@ def run_pipeline(
877
910
  persist_tile_embeddings=persist_tile_embeddings,
878
911
  persist_hierarchical_embeddings=persist_hierarchical_embeddings,
879
912
  include_slide_embeddings=include_slide_embeddings,
880
- save_latents=execution.save_latents,
913
+ save_latents=embedding.should_persist_latents(model, execution),
881
914
  resume=resolved_preprocessing.resume,
882
- requested_tile_size_px=resolved_preprocessing.requested_tile_size_px,
915
+ identity=feature_identity.pooled_feature_identity(
916
+ model, execution=execution, preprocessing=resolved_preprocessing
917
+ ),
918
+ resolve_transform=feature_identity.deferred_transform_record(
919
+ model, on_cpu_copy=False, preprocessing=resolved_preprocessing
920
+ ),
883
921
  )
884
922
  skipped_slide_count = len(embeddable_slides) - len(pending_slides)
885
923
  if resolved_preprocessing.resume and skipped_slide_count > 0:
@@ -992,8 +1030,7 @@ def run_pipeline_with_coordinates(
992
1030
  zero_tile_pairs,
993
1031
  model=model,
994
1032
  preprocessing=resolved_preprocessing,
995
- output_dir=output_dir,
996
- output_format=execution.output_format,
1033
+ execution=execution,
997
1034
  )
998
1035
  emit_progress("embedding.started", slide_count=len(embeddable_slides))
999
1036
  if execution.num_gpus > 1:
@@ -5,6 +5,7 @@ from typing import Callable, Sequence
5
5
 
6
6
  import pandas as pd
7
7
  from hs2p import SlideSpec
8
+ from hs2p.fileops import read_csv_keyed_by_sample_id
8
9
 
9
10
  from slide2vec.api import EmbeddedSlide, ExecutionOptions, PreprocessingConfig
10
11
  from slide2vec.artifacts import (
@@ -15,8 +16,12 @@ from slide2vec.artifacts import (
15
16
  )
16
17
  from slide2vec.runtime.distributed_stage import run_distributed_embedding_stage
17
18
  from slide2vec.runtime.embedding_persist import persist_embedded_slide
19
+ from slide2vec.runtime.feature_identity import (
20
+ deferred_transform_record,
21
+ pooled_feature_identity,
22
+ )
18
23
  from slide2vec.runtime.hierarchical import is_hierarchical_preprocessing
19
- from slide2vec.runtime.embedding import should_persist_tile_embeddings
24
+ from slide2vec.runtime.embedding import should_persist_latents, should_persist_tile_embeddings
20
25
  from slide2vec.runtime.persistence import (
21
26
  collect_pipeline_artifacts,
22
27
  update_process_list_after_embedding,
@@ -73,7 +78,7 @@ def _embeddable_annotation_groups(
73
78
  """
74
79
  if process_list_path is None or not Path(process_list_path).is_file():
75
80
  return {}
76
- df = pd.read_csv(process_list_path)
81
+ df = read_csv_keyed_by_sample_id(process_list_path)
77
82
  if "sample_id" not in df.columns:
78
83
  return {}
79
84
  has_annotation = "annotation" in df.columns
@@ -164,6 +169,7 @@ def collect_distributed_pipeline_artifacts(
164
169
  persist_hierarchical_embeddings = is_hierarchical_preprocessing(preprocessing)
165
170
  include_slide_embeddings = model.level == "slide"
166
171
  include_tile_embeddings = persist_tile_embeddings and not persist_hierarchical_embeddings
172
+ save_latents = should_persist_latents(model, execution)
167
173
  # Every persisted embedding kind can fan out per (sample_id, annotation); the process list
168
174
  # (one row per pair after hs2p tiling) is the source of truth for which classes exist.
169
175
  annotation_aware = (
@@ -191,9 +197,13 @@ def collect_distributed_pipeline_artifacts(
191
197
  persist_tile_embeddings=persist_tile_embeddings,
192
198
  persist_hierarchical_embeddings=persist_hierarchical_embeddings,
193
199
  include_slide_embeddings=include_slide_embeddings,
194
- save_latents=execution.save_latents,
200
+ save_latents=save_latents,
195
201
  resume=preprocessing.resume,
196
- requested_tile_size_px=preprocessing.requested_tile_size_px,
202
+ identity=pooled_feature_identity(model, execution=execution, preprocessing=preprocessing),
203
+ # This parent never encodes: verify the transform without taking GPU memory.
204
+ resolve_transform=deferred_transform_record(
205
+ model, on_cpu_copy=True, preprocessing=preprocessing
206
+ ),
197
207
  )
198
208
  pending_annotations = [placeholder.annotation for placeholder in pending_placeholders]
199
209
  skipped_slide_count = len(successful_slides) - len(pending_slides)
@@ -228,7 +238,7 @@ def collect_distributed_pipeline_artifacts(
228
238
  persist_tile_embeddings=persist_tile_embeddings,
229
239
  persist_hierarchical_embeddings=persist_hierarchical_embeddings,
230
240
  include_slide_embeddings=include_slide_embeddings,
231
- save_latents=execution.save_latents,
241
+ save_latents=save_latents,
232
242
  annotation=annotation,
233
243
  )
234
244
  for annotation in sample_annotations