Skip to main content
Tiled tissue mask generation using a batched segmentation model. Implements TiledTissueMask, which walks a WSI in fixed-size patches, processes them through a TissueMaskModel, and stitches the per-tile predictions into a full-slide binary mask.

TiledTissueMask

Tile-based, batch-aware tissue mask generation. Combines a TissueMaskModel with a tiling strategy to produce a full-slide binary mask. The tile size and resolution are taken from the model’s tile spec. The workflow (see generate) is:
  1. Compute the tissue bounding box at the model’s resolution.
  2. Walk the bounding box in non-overlapping, tile-spec-sized patches.
  3. Read patches sequentially and dispatch them concurrently to the model endpoint for GPU-efficient batched inference.
  4. Stitch the per-tile masks back into the output array.
Boundary tiles smaller than the tile size are zero-padded before processing and the padding is stripped from the output.
The segmentation model. Its tile spec supplies the tile size and resolution used for tiling.
Example:

generate

Generates a tissue mask by tiling over the WSI. Tile images are read sequentially from the WSI (readers are not thread-safe), then dispatched concurrently to the remote model endpoint for GPU-efficient batched inference. Results are stitched back into a single binary mask.
An open WSI reader.
Whether to display a per-tile progress bar. Defaults to True.
Maximum concurrent HTTP requests. Defaults to 64.
Returns: A uint8 mask of shape (H, W) covering the tissue bounding box at resolution, with values in {0, 1} where 1 = tissue.