Skip to content

pixano_inference.schemas.segmentation

Segmentation I/O types.

SegmentationInput(**data)

Bases: _BaseModel

Input for image segmentation.

Attributes:

Name Type Description
image str | Path | bytes

Image for segmentation (path, URL, or base64).

image_embedding NDArrayFloat | None

Pre-computed image embedding.

high_resolution_features list[NDArrayFloat] | None

High resolution features.

mask_input NDArrayFloat | None

Low-resolution mask logits from a previous refinement round.

reset_predictor bool

True (default) for a new image. If False, keep current predictor.

points list[list[list[int]]] | None

Point prompts [num_prompts, num_points, 2].

labels list[list[int]] | None

Labels for points [num_prompts, num_points].

boxes list[list[int]] | None

Box prompts [num_prompts, 4].

num_multimask_outputs int

Number of masks to generate per prediction.

multimask_output bool

Whether to generate multiple masks per prediction.

return_image_embedding bool

Whether to return the image embeddings.

return_logits bool

Whether to return low-resolution logits for iterative refinement.

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,
        )

SegmentationOutput(**data)

Bases: _BaseModel

Output for image segmentation.

Attributes:

Name Type Description
masks list[list[CompressedRLE]]

Generated masks [num_predictions, num_masks_per_prediction].

scores NDArrayFloat

Scores of the masks.

image_embedding NDArrayFloat | None

Image embeddings (optional).

high_resolution_features list[NDArrayFloat] | None

High resolution features (optional).

mask_logits NDArrayFloat | None

Low-resolution logits for iterative refinement (optional).

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,
        )