> ## 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` 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** 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.

<ParamField body="request" type="ModelRequest" required>
  Model request containing the RGB tile.
</ParamField>

<ResponseField name="returns" type="ModelResponse">
  Model response containing the binary mask.
</ResponseField>
