pixano_inference.models.detection
Detection model base class and I/O types.
DetectionInput(**data)
Bases: BaseModel
Input for detection.
When classes is provided the model runs in open-vocabulary mode
(e.g. GroundingDINO, YOLOE with text prompt). When classes is
None the model uses its built-in class set (closed-vocabulary
mode, e.g. YOLO, prompt-free YOLOE).
Attributes:
| Name | Type | Description |
|---|---|---|
image |
str | Path
|
Image for detection (path, URL, or base64). |
classes |
list[str] | str | None
|
Class names to detect. |
box_threshold |
float
|
Confidence threshold for boxes. |
text_threshold |
float
|
Confidence threshold for text matching (open-vocab only). |
Source code in pydantic/main.py
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. |
Source code in pixano_inference/models/detection.py
DetectionOutput(**data)
Bases: BaseModel
Output for detection.
masks is populated when the model performs instance segmentation
(boxes + masks). For detection-only models it is None.
Attributes:
| Name | Type | Description |
|---|---|---|
boxes |
list[list[int]]
|
List of detected boxes. |
scores |
list[float]
|
List of confidence scores. |
classes |
list[str]
|
List of class names associated with each box. |
masks |
list[CompressedRLE] | None
|
Optional instance masks in compressed-RLE format. |