"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
import io
from livepeer_ai.types import BaseModel
from livepeer_ai.utils import FieldMetadata, MultipartFormMetadata
import pydantic
from typing import IO, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict


class BodyGenSegmentAnything2ImageTypedDict(TypedDict):
    file_name: str
    content: Union[bytes, IO[bytes], io.BufferedReader]
    content_type: NotRequired[str]


class BodyGenSegmentAnything2Image(BaseModel):
    file_name: Annotated[
        str, pydantic.Field(alias="image"), FieldMetadata(multipart=True)
    ]

    content: Annotated[
        Union[bytes, IO[bytes], io.BufferedReader],
        pydantic.Field(alias=""),
        FieldMetadata(multipart=MultipartFormMetadata(content=True)),
    ]

    content_type: Annotated[
        Optional[str],
        pydantic.Field(alias="Content-Type"),
        FieldMetadata(multipart=True),
    ] = None


class BodyGenSegmentAnything2TypedDict(TypedDict):
    image: BodyGenSegmentAnything2ImageTypedDict
    r"""Image to segment."""
    model_id: NotRequired[str]
    r"""Hugging Face model ID used for image generation."""
    point_coords: NotRequired[str]
    r"""Nx2 array of point prompts to the model, where each point is in (X,Y) in pixels."""
    point_labels: NotRequired[str]
    r"""Labels for the point prompts, where 1 indicates a foreground point and 0 indicates a background point."""
    box: NotRequired[str]
    r"""A length 4 array given as a box prompt to the model, in XYXY format."""
    mask_input: NotRequired[str]
    r"""A low-resolution mask input to the model, typically from a previous prediction iteration, with the form 1xHxW (H=W=256 for SAM)."""
    multimask_output: NotRequired[bool]
    r"""If true, the model will return three masks for ambiguous input prompts, often producing better masks than a single prediction."""
    return_logits: NotRequired[bool]
    r"""If true, returns un-thresholded mask logits instead of a binary mask."""
    normalize_coords: NotRequired[bool]
    r"""If true, the point coordinates will be normalized to the range [0,1], with point_coords expected to be with respect to image dimensions."""


class BodyGenSegmentAnything2(BaseModel):
    image: Annotated[
        BodyGenSegmentAnything2Image,
        pydantic.Field(alias=""),
        FieldMetadata(multipart=MultipartFormMetadata(file=True)),
    ]
    r"""Image to segment."""

    model_id: Annotated[Optional[str], FieldMetadata(multipart=True)] = ""
    r"""Hugging Face model ID used for image generation."""

    point_coords: Annotated[Optional[str], FieldMetadata(multipart=True)] = None
    r"""Nx2 array of point prompts to the model, where each point is in (X,Y) in pixels."""

    point_labels: Annotated[Optional[str], FieldMetadata(multipart=True)] = None
    r"""Labels for the point prompts, where 1 indicates a foreground point and 0 indicates a background point."""

    box: Annotated[Optional[str], FieldMetadata(multipart=True)] = None
    r"""A length 4 array given as a box prompt to the model, in XYXY format."""

    mask_input: Annotated[Optional[str], FieldMetadata(multipart=True)] = None
    r"""A low-resolution mask input to the model, typically from a previous prediction iteration, with the form 1xHxW (H=W=256 for SAM)."""

    multimask_output: Annotated[Optional[bool], FieldMetadata(multipart=True)] = True
    r"""If true, the model will return three masks for ambiguous input prompts, often producing better masks than a single prediction."""

    return_logits: Annotated[Optional[bool], FieldMetadata(multipart=True)] = True
    r"""If true, returns un-thresholded mask logits instead of a binary mask."""

    normalize_coords: Annotated[Optional[bool], FieldMetadata(multipart=True)] = True
    r"""If true, the point coordinates will be normalized to the range [0,1], with point_coords expected to be with respect to image dimensions."""
