Skip to main content

Python library for run inference of deep learning models in different backends

Project description

InferenceMultiBackend

Python library for run inference of deep learning models in different backends

Installation

For use triton inference client: pip install imb[triton]

For use onnxruntime-gpu client: pip install imb[onnxgpu]

For use onnxruntime client: pip install imb[onnxcpu]

For support all implemented clients: pip install imb[all]

Usage

OnnxClient usage example

from imb.onnx import OnnxClient

onnx_client = OnnxClient(
    model_path='model.onnx',
    model_name='any name',
    providers=['CUDAExecutionProvider', 'CPUExecutionProvider'],
    max_batch_size=16,
    return_dict=True,
    fixed_batch=True,
    warmup=True
)

# if model has fixed input size (except batch size) then sample_inputs will be created
sample_inputs = onnx_client.sample_inputs
print('inputs shapes', [o.shape for o in sample_inputs])

outputs = onnx_client(*sample_inputs)
print('outputs shapes', [(o_name, o_value.shape) for o_name, o_value in outputs.items()])

TritonClient usage example

from imb.triton import TritonClient

triton_client = TritonClient(
    url='localhost:8000',
    model_name='arcface',
    max_batch_size=16,
    timeout=10,
    resend_count=10,
    fixed_batch=True,
    is_async=False,
    cuda_shm=False,
    max_shm_regions=2,
    scheme='http',
    return_dict=True,
    warmup=False
)

# if model has fixed input size (except batch size) then sample_inputs will be created
sample_inputs = triton_client.sample_inputs
print('inputs shapes', [o.shape for o in sample_inputs])

outputs = triton_client(*sample_inputs)
print('outputs shapes', [(o_name, o_value.shape) for o_name, o_value in outputs.items()])

Notes

max_batch_size - maximum batch size for inference. If input data larger that max_batch_size, then input data will be splitted to several batches.

fixed_batch - if fixed batch is True, then each batch will have fixed size (padding the smallest batch to max_batch_size).

warmup - if True, model will run several calls on sample_inputs while initialization.

return_dict - if True, call return dict {'output_name1': output_value1, ...}, else [output_value1, ...]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imb-1.0.2.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imb-1.0.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file imb-1.0.2.tar.gz.

File metadata

  • Download URL: imb-1.0.2.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for imb-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8ef861f5e303f6d6c9bc1c8edd2545dd01ca5e05009924918cf4901a00c7c81f
MD5 cb7a92deb67a04edd96f0d53e761e134
BLAKE2b-256 f0feb793984335835c91cc53b31b29faf91abdd1333a0c20850cc440e0202c77

See more details on using hashes here.

File details

Details for the file imb-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: imb-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for imb-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a9386fc16248ddf026b803e9e79f231ada7201e2f5ecf88e3448da08ad2cf7a2
MD5 09f457474032866a784ed9e83ed4173e
BLAKE2b-256 d374acc9c82bbac70b76fe35de7a81c96cf258a10d4a980f98b28f2224270cab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page