xwhy.models.BaseSegmentation¶
Bases: ABC
Base class for all segmentation implementations.
Source code in src/xwhy/models/segmentation/base.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
model
abstractmethod
property
¶
Read-only property to access the underlying raw segmentation model.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the model has not been loaded into memory yet. |
Returns:
| Type | Description |
|---|---|
Any
|
The loaded raw segmentation model object. |
preprocess_fn
abstractmethod
property
¶
Read-only property to access the preprocessing transform function.
Returns:
| Type | Description |
|---|---|
Callable[..., Any] | None
|
The callable preprocessing function, or None if not applicable. |
class_names
abstractmethod
property
¶
Return the list of class names (categories) supported by the model.
__call__(inputs)
abstractmethod
¶
Execute the forward pass of the segmentation model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
Any
|
The preprocessed inputs (e.g., a PyTorch tensor). |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The segmentation masks or logits output by the model. |
Source code in src/xwhy/models/segmentation/base.py
38 39 40 41 42 43 44 45 46 47 48 49 | |
load()
abstractmethod
¶
Load segmentation model into memory.
Source code in src/xwhy/models/segmentation/base.py
57 58 59 60 | |
predict(inputs)
abstractmethod
¶
Run inference on the given inputs and return predictions/masks.
Source code in src/xwhy/models/segmentation/base.py
62 63 64 65 | |