> ## 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.models.base

Abstract interface for tissue segmentation models.

Defines the [`TissueMaskModel`](https://docs.bioptimus.com/sdk-reference/preprocess/wsi/models/base#tissuemaskmodel) abstract base class used by tissue mask providers to process individual tile requests into binary segmentation masks.

## TissueMaskModel

```python theme={null}
class TissueMaskModel(ABC)
```

Abstract interface for tissue segmentation models.

Accepts a **batch** of fixed-size RGB tiles and returns a batch of binary masks.  GPU-backed models can process the whole batch at once; CPU-only models (like Otsu) can iterate internally.

The batch dimension is always the first axis:

* Input:  `(B, H, W, 3)` — `uint8` RGB.
* Output: `(B, H, W)`    — `uint8`, values in `{0, 1}`.

**Example**:

```python theme={null}
class MyGPUModel(TissueMaskModel):
    def __init__(self, net):
        self.net = net

    def process(self, batch):
        tensor = torch.from_numpy(batch).permute(0, 3, 1, 2).float() / 255
        with torch.no_grad():
            logits = self.net(tensor.cuda())
        return (logits.squeeze(1).cpu().numpy() > 0.5).astype(np.uint8)
```

***

#### tile\_spec

```python theme={null}
@property
@abstractmethod
def tile_spec() -> TileSpec | None
```

Returns the tile specification for this model, or `None`.

Subclasses must implement this property. Return `None` for models that operate on arbitrary tile sizes.

***

#### process

```python theme={null}
@abstractmethod
def process(request: ModelRequest) -> ModelResponse
```

Processes a single RGB tile into a binary mask.

**request**

Model request containing the RGB tile.

**Returns**:

* `ModelResponse` - Model response containing the binary mask.


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