Skip to content

pixano_inference.schemas.detection

Detection 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 | bytes

Image for detection (path, URL, base64, or raw bytes from the binary route).

classes list[str] | str | None

Class names to detect. None means closed-vocabulary.

box_threshold float

Confidence threshold for boxes.

text_threshold float

Confidence threshold for text matching (open-vocab only).

Source code in pydantic/main.py
def __init__(self, /, **data: Any) -> None:
    """Create a new model by parsing and validating input data from keyword arguments.

    Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be
    validated to form a valid model.

    `self` is explicitly positional-only to allow `self` as a field name.
    """
    # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    __tracebackhide__ = True
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    if self is not validated_self:
        warnings.warn(
            'A custom validator is returning a value other than `self`.\n'
            "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
            f'See the `model_validator` docs (https://pydantic.dev/docs/validation/{version_short()}/concepts/validators/#model-validators) for more details.',
            stacklevel=2,
        )

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.

Source code in pydantic/main.py
def __init__(self, /, **data: Any) -> None:
    """Create a new model by parsing and validating input data from keyword arguments.

    Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be
    validated to form a valid model.

    `self` is explicitly positional-only to allow `self` as a field name.
    """
    # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    __tracebackhide__ = True
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    if self is not validated_self:
        warnings.warn(
            'A custom validator is returning a value other than `self`.\n'
            "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
            f'See the `model_validator` docs (https://pydantic.dev/docs/validation/{version_short()}/concepts/validators/#model-validators) for more details.',
            stacklevel=2,
        )