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 workflow is:
  1. Compute the tissue bounding box at resolution.
  2. Walk the bounding box in non-overlapping tile_size patches.
  3. Collect patches into batches of batch_size.
  4. Pass each batch to model.process() — this is where GPU parallelism happens for DL models.
  5. Stitch the per-tile masks back into the output array.
Boundary tiles that are smaller than tile_size are zero-padded before model processing and the padding is stripped from the output.
TissueMaskModel
The processing model.
tuple[int, int] | None
(width, height) of each patch. When None, derived from model.tile_spec.
Resolution | None
Resolution at which to read tiles. When None, derived from model.tile_spec.
int
Number of tiles per model call. Set higher for GPU models (e.g. 32–64). Defaults to 1.
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.
WSIReader
required
An open WSI reader.
bool
Whether to display a per-tile progress bar. Defaults to True.
int
Maximum concurrent HTTP requests. Defaults to 64.
np.ndarray
A uint8 mask of shape (H, W) covering the tissue bounding box at resolution, with values in {0, 1} where 1 = tissue.