pixano_inference.models.detection
Detection model base class.
The I/O types (:class:DetectionInput/:class:DetectionOutput) are the wire contract and live
in :mod:pixano_inference_client.detection; they are re-exported here so
from pixano_inference.models.detection import DetectionInput keeps working.
DetectionModel(config)
Bases: InferenceModel
Base class for detection and instance-segmentation models.
Subclasses implement predict which receives a :class:DetectionInput
and returns a :class:DetectionOutput. The same pair of types covers
both pure detection (no masks) and instance segmentation (with masks).
Example
@register_model("my-detector")
class MyDetector(DetectionModel):
def load_model(self):
self.model = load_weights(self.config.model_params["path"])
def predict(self, input: DetectionInput) -> DetectionOutput:
boxes, scores, cls = self.model(input.image, input.classes)
return DetectionOutput(boxes=boxes, scores=scores, classes=cls)
Source code in pixano_inference/models/base.py
predict(input)
abstractmethod
Run detection or instance segmentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
DetectionInput
|
Detection input with image, optional classes, and thresholds. |
required |
Returns:
| Type | Description |
|---|---|
DetectionOutput
|
Detection output with boxes, scores, classes, and optional masks. |