> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bioptimus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# bioptimus.preprocess.wsi.provider.tiled

Tiled tissue mask generation using a batched segmentation model.

Implements [`TiledTissueMask`](https://docs.bioptimus.com/sdk-reference/preprocess/wsi/provider/tiled#tiledtissuemask), which walks a WSI in fixed-size patches, processes them through a [`TissueMaskModel`](https://docs.bioptimus.com/sdk-reference/preprocess/wsi/models/base#tissuemaskmodel), and stitches the per-tile predictions into a full-slide binary mask.

## TiledTissueMask

```python theme={null}
class TiledTissueMask(model: TissueMaskModel)
```

Tile-based, batch-aware tissue mask generation.

Combines a [`TissueMaskModel`](https://docs.bioptimus.com/sdk-reference/preprocess/wsi/models/base#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`](https://docs.bioptimus.com/sdk-reference/preprocess/wsi/provider/tiled#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.

**model**

The segmentation model. Its tile spec supplies the tile size and resolution used for tiling.

**Example**:

```python theme={null}
provider = TiledTissueMask(model=my_model)
mask = provider.generate(reader)
```

***

#### generate

```python theme={null}
def generate(reader: WSIReader,
             *,
             show_progress: bool = True,
             max_concurrency: int = _DEFAULT_MAX_CONCURRENCY) -> np.ndarray
```

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.

**reader**

An **open** WSI reader.

**show\_progress**

Whether to display a per-tile progress bar. Defaults to `True`.

**max\_concurrency**

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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.