pixano_inference.client
Pixano inference client.
InferenceTooLongError
Bases: Exception
Exeption when inference took too long.
PixanoInferenceClient(**data)
Bases: Settings
Pixano Inference Client.
Source code in pixano_inference/settings.py
_rest_call(path, method, timeout=60, **kwargs)
async
Perform a REST call to the pixano inference server.
Source code in pixano_inference/client.py
connect(url)
staticmethod
Connect to pixano inference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL of the pixano inference server. |
required |
Source code in pixano_inference/client.py
delete(path, **kwargs)
async
delete_model(model_name)
async
Delete a model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
The name of the model. |
required |
get(path, **kwargs)
async
get_settings()
async
Get the settings for the pixano inference server.
image_mask_generation(request=None, poll_interval=0.1, timeout=60, task_id=None, asynchronous=False)
async
image_mask_generation(request: ImageMaskGenerationRequest | None, poll_interval: float, timeout: float, task_id: str, asynchronous: Literal[True]) -> ImageMaskGenerationResponse | CeleryTask
image_mask_generation(request: ImageMaskGenerationRequest | None, poll_interval: float, timeout: float, task_id: None, asynchronous: Literal[True]) -> CeleryTask
Perform an inference to perform image mask generation.
Source code in pixano_inference/client.py
image_zero_shot_detection(request=None, poll_interval=0.1, timeout=60, task_id=None, asynchronous=False)
async
image_zero_shot_detection(request: ImageZeroShotDetectionRequest | None, poll_interval: float, timeout: float, task_id: str, asynchronous: Literal[True]) -> ImageZeroShotDetectionResponse | CeleryTask
image_zero_shot_detection(request: ImageZeroShotDetectionRequest | None, poll_interval: float, timeout: float, task_id: None, asynchronous: Literal[True]) -> CeleryTask
Perform an inference to perform video mask generation.
Source code in pixano_inference/client.py
inference(route, request=None, response_type=None, poll_interval=0.1, timeout=60.0, task_id=None, asynchronous=False)
async
inference(route: str, request: BaseRequest | None, response_type: type[BaseResponse] | None, poll_interval: float, timeout: float, task_id: str, asynchronous: Literal[True]) -> BaseResponse | CeleryTask
inference(route: str, request: BaseRequest | None, response_type: type[BaseResponse] | None, poll_interval: float, timeout: float, task_id: None, asynchronous: Literal[True]) -> CeleryTask
Perform a POST request to the pixano inference server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
route
|
str
|
The root to the request. |
required |
request
|
BaseRequest | None
|
The request of the model. |
None
|
response_type
|
type[BaseResponse] | None
|
The type of the response. |
None
|
poll_interval
|
float
|
waiting time between subsequent requests to server to retrieve task results for synchronous requests. |
0.1
|
timeout
|
float
|
Time to wait for response for synchronous requests. If reached, the request will be aborted. |
60.0
|
task_id
|
str | None
|
The id of the task to poll for results. |
None
|
asynchronous
|
bool
|
If True then the function will be called asynchronously and returns a CeleryTask object or poll results when task id is provided. |
False
|
Returns:
Type | Description |
---|---|
BaseResponse | CeleryTask
|
A response from the pixano inference server. |
Source code in pixano_inference/client.py
instantiate_model(provider, config, timeout=60)
async
Instantiate a model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provider
|
str
|
The model provider. |
required |
config
|
ModelConfig
|
The configuration of the model. |
required |
timeout
|
int
|
The timeout to wait for a response. Please note that even if the timeout is reached, the request will not be aborted. |
60
|
Source code in pixano_inference/client.py
list_models()
async
post(path, **kwargs)
async
put(path, **kwargs)
async
text_image_conditional_generation(request=None, poll_interval=0.1, timeout=60, task_id=None, asynchronous=False)
async
text_image_conditional_generation(request: TextImageConditionalGenerationRequest | None, poll_interval: float, timeout: float, task_id: str, asynchronous: Literal[True]) -> TextImageConditionalGenerationResponse | CeleryTask
text_image_conditional_generation(request: TextImageConditionalGenerationRequest | None, poll_interval: float, timeout: float, task_id: None, asynchronous: Literal[True]) -> CeleryTask
Perform an inference to perform text-image conditional generation.
Source code in pixano_inference/client.py
video_mask_generation(request=None, poll_interval=0.1, timeout=60, task_id=None, asynchronous=False)
async
video_mask_generation(request: VideoMaskGenerationRequest | None, poll_interval: float, timeout: float, task_id: str, asynchronous: Literal[True]) -> VideoMaskGenerationResponse | CeleryTask
video_mask_generation(request: VideoMaskGenerationRequest | None, poll_interval: float, timeout: float, task_id: None, asynchronous: Literal[True]) -> CeleryTask
Perform an inference to perform video mask generation.
Source code in pixano_inference/client.py
raise_if_error(response)
Raise an error from a response.