pixano_inference.models.segmentation
Segmentation model base class.
The I/O types (:class:SegmentationInput/:class:SegmentationOutput) are the wire contract and
live in :mod:pixano_inference_client.segmentation; they are re-exported here so
from pixano_inference.models.segmentation import SegmentationInput keeps working.
SegmentationModel(config)
Bases: InferenceModel
Base class for image segmentation models.
Example
@register_model("my-segmenter")
class MySegmenter(SegmentationModel):
def load_model(self):
self.model = load_weights(self.config.model_params["path"])
def predict(self, input: SegmentationInput) -> SegmentationOutput:
masks, scores = self.model(input.image, input.points, input.labels, input.boxes)
return SegmentationOutput(masks=masks, scores=scores)
Source code in pixano_inference/models/base.py
predict(input)
abstractmethod
Run image segmentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
SegmentationInput
|
Segmentation input with image, prompts, and options. |
required |
Returns:
| Type | Description |
|---|---|
SegmentationOutput
|
Segmentation output with masks, scores, and optionally embeddings. |