Skip to content

pixano_inference.providers.base

Base classes for providers.

APIProvider(**kwargs)

Bases: BaseProvider

Base class for API providers.

Source code in pixano_inference/providers/base.py
def __init__(self, **kwargs: Any):
    """Initialize the provider."""
    pass

api_url abstractmethod property

URL of the API.

send_request(request) abstractmethod

Send a request to the API and return the response.

Parameters:

Name Type Description Default
request APIRequest

Request to send.

required

Returns:

Type Description
BaseResponse

Response from the API.

Source code in pixano_inference/providers/base.py
@abstractmethod
def send_request(self, request: APIRequest) -> BaseResponse:
    """Send a request to the API and return the response.

    Args:
        request: Request to send.

    Returns:
        Response from the API.
    """
    ...

BaseProvider(**kwargs)

Bases: ABC

Base class for providers.

Source code in pixano_inference/providers/base.py
def __init__(self, **kwargs: Any):
    """Initialize the provider."""
    pass

image_mask_generation(request, model, *args, **kwargs)

Generate a mask from the image.

Parameters:

Name Type Description Default
request ImageMaskGenerationRequest

Request for the generation.

required
model BaseInferenceModel

Model to use for the generation.

required
args Any

Additional arguments.

()
kwargs Any

Additional keyword arguments.

{}
Source code in pixano_inference/providers/base.py
def image_mask_generation(
    self, request: ImageMaskGenerationRequest, model: BaseInferenceModel, *args: Any, **kwargs: Any
) -> ImageMaskGenerationOutput:
    """Generate a mask from the image.

    Args:
        request: Request for the generation.
        model: Model to use for the generation.
        args: Additional arguments.
        kwargs: Additional keyword arguments.
    """
    raise NotImplementedError("This provider does not support image mask generation.")

image_zero_shot_detection(request, model, *args, **kwargs)

Perform zero-shot image detection.

Source code in pixano_inference/providers/base.py
def image_zero_shot_detection(
    self, request: ImageZeroShotDetectionRequest, model: BaseInferenceModel, *args: Any, **kwargs: Any
) -> ImageZeroShotDetectionOutput:
    """Perform zero-shot image detection."""
    raise NotImplementedError("This provider does not support image zero-shot detection.")

text_image_conditional_generation(request, model, *args, **kwargs)

Generate an image from the text and image.

Parameters:

Name Type Description Default
request TextImageConditionalGenerationRequest

Request for the generation.

required
model BaseInferenceModel

Model to use for the generation.

required
args Any

Additional arguments.

()
kwargs Any

Additional keyword arguments.

{}

Returns:

Type Description
TextImageConditionalGenerationOutput

Output of the generation

Source code in pixano_inference/providers/base.py
def text_image_conditional_generation(
    self, request: TextImageConditionalGenerationRequest, model: BaseInferenceModel, *args: Any, **kwargs: Any
) -> TextImageConditionalGenerationOutput:
    """Generate an image from the text and image.

    Args:
        request: Request for the generation.
        model: Model to use for the generation.
        args: Additional arguments.
        kwargs: Additional keyword arguments.

    Returns:
        Output of the generation
    """
    raise NotImplementedError("This provider does not support text-image conditional generation.")

video_mask_generation(request, model, *args, **kwargs)

Generate a mask from the video.

Parameters:

Name Type Description Default
request VideoMaskGenerationRequest

Request for the generation.

required
model BaseInferenceModel

Model to use for the generation.

required
args Any

Additional arguments.

()
kwargs Any

Additional keyword arguments.

{}

Returns:

Type Description
VideoMaskGenerationOutput

Output of the generation

Source code in pixano_inference/providers/base.py
def video_mask_generation(
    self, request: VideoMaskGenerationRequest, model: BaseInferenceModel, *args: Any, **kwargs: Any
) -> VideoMaskGenerationOutput:
    """Generate a mask from the video.

    Args:
        request: Request for the generation.
        model: Model to use for the generation.
        args: Additional arguments.
        kwargs: Additional keyword arguments.

    Returns:
        Output of the generation
    """
    raise NotImplementedError("This provider does not support video mask generation.")

ModelProvider(**kwargs)

Bases: BaseProvider

Base class for model providers.

Source code in pixano_inference/providers/base.py
def __init__(self, **kwargs: Any):
    """Initialize the provider."""
    pass

load_model(name, task, device, path=None, processor_config={}, config={}) abstractmethod

Load the model from the provider.

Parameters:

Name Type Description Default
name str

Name of the model.

required
task Task | str

Task of the model.

required
device device

Device to use for the model.

required
path Path | str | None

Path to the model.

None
processor_config dict

Processor configuration.

{}
config dict

Configuration for the model.

{}

Returns:

Type Description
BaseInferenceModel

The loaded model.

Source code in pixano_inference/providers/base.py
@abstractmethod
def load_model(
    self,
    name: str,
    task: Task | str,
    device: "torch.device",
    path: Path | str | None = None,
    processor_config: dict = {},
    config: dict = {},
) -> "BaseInferenceModel":
    """Load the model from the provider.

    Args:
        name: Name of the model.
        task: Task of the model.
        device: Device to use for the model.
        path: Path to the model.
        processor_config: Processor configuration.
        config: Configuration for the model.

    Returns:
        The loaded model.
    """
    ...