hs2p provides a single batch entrypoint:
hs2p /path/to/config.yaml [opts...]
The mask_path column in the input CSV is interpreted as a tissue mask.
Multi-label annotation sampling is driven by the same entrypoint via tiling.masks config.
sample_id,image_path,mask_path
slide-1,/data/slide-1.tif,/data/slide-1-tissue-mask.tif
slide-2,/data/slide-2.tif,
...sample_id,image_path,mask_path
slide-1,/data/slide-1.tif,/data/slide-1-annotations.tif
slide-2,/data/slide-2.tif,/data/slide-2-annotations.tif
...Works in either mode:
sample_id,image_path,mask_path,spacing_at_level_0
slide-1,/data/slide-1.tif,,0.25
slide-2,/data/slide-2.tif,/data/slide-2-tissue-mask.tif,
...Start from hs2p/configs/default.yaml, then edit:
csvoutput_dirtiling.backendtiling.params.requested_spacing_umtiling.params.requested_tile_size_px
Run:
hs2p /path/to/config.yamlBase install:
pip install hs2pOptional extras:
pip install "hs2p[openslide]"
pip install "hs2p[asap]"
pip install "hs2p[vips]"
pip install "hs2p[cucim]"
pip install "hs2p[all]"tiling.backend supports:
autocucimvipsopenslideasap
auto prefers cucim -> vips -> openslide -> asap.
tiling.read_coordinates_from- Reuse precomputed
{sample_id}.coordinates.*artifacts
- Reuse precomputed
tiling.params- spacing, tile size, overlap, tolerance, padding, and minimum tissue fraction
tiling.seg_params- tissue segmentation settings
methodselectshsv,otsu,threshold, orsam2
tiling.filter_params- contour and optional white/black filtering settings
tiling.preview- preview rendering settings
saveenables both batch mask previews and tiling previewsdownsamplecontrols preview resolutiontissue_contour_colorcontrols the RGB border color used forpreview/mask/*.jpgmask_overlay_alphacontrols opacity for the filled annotation-mask overlay path; contour-only previews ignore it
tiling.masks- multi-label annotation sampling (pixel_mapping, color_mapping, min_coverage)
- when absent, defaults to binary tissue tiling
save_tiles- write
tiles/{sample_id}.tiles.tar
- write
speed.num_workers- slide-level batch parallelism
When stdout is interactive, the entrypoint uses rich live progress:
- shows discovered tile totals during the run
- finishes with a summary panel including output locations and
process_list.csv
When stdout is non-interactive, hs2p falls back to concise plain-text progress and summary logs.
Detailed logs still go to output_dir/logs/log.txt.
resume: trueexpects the current process-list schema- reused artifacts are validated against structured metadata, not
config_hash tiling.read_coordinates_fromis the supported way to reuse precomputed coordinate artifacts
tiling.seg_params.downsample controls the resolution used for tissue segmentation:
- larger values are faster and coarser
- smaller values improve edge precision but cost more time and memory
tiling.seg_params.method controls how the segmentation mask is generated at that level:
hsvuses the existing HSV heuristicotsuthresholds the saturation channel with Otsuthresholdapplies a fixed saturation thresholdsam2runs SAM2 inference on an internal fixed8.0 um/pxthumbnail- hs2p chooses the thumbnail level in physical units first, then resizes to the requested spacing only if the nearest pyramid level is outside tolerance
- if
sam2_checkpoint_pathis empty, hs2p downloads the default AtlasPatch checkpoint from Hugging Face - if
sam2_config_pathis empty, hs2p downloads the default AtlasPatch SAM2 config from Hugging Face tiling.seg_params.downsampleis ignored by SAM2
tiling.filter_params.filter_white, filter_black, filter_grayspace, and filter_blur are disabled by default.
When enabled, hs2p evaluates candidate tiles at tiling.filter_params.qc_spacing_um, which is typically coarser than the final extraction spacing. This is still slower than mask-only tiling, but cheaper than running pixel QC at the requested tile spacing.
When save_tiles: true, hs2p also writes tiles/{sample_id}.tiles.tar.
- non-CuCIM paths coalesce dense tile regions before slicing them back into tiles
- CuCIM paths use batched reads
gpu_decode=Trueis opt-in in the Python API for CuCIM tar export
See artifacts.md for the exact coordinate artifact schema and process-list columns.