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

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

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.1.tar.gz (9.9 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.1-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: imb-1.0.1.tar.gz
  • Upload date:
  • Size: 9.9 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.1.tar.gz
Algorithm Hash digest
SHA256 13a6f6233cb0063c6f6464038cfc2e39421db748d307e86d8b79b43625c349ad
MD5 3a08ef7529979c54de0290fd0b2ba4bb
BLAKE2b-256 a4a4971abddd552ad4f9cb04313347a39747a29271592f8ab4dbb992da655fbb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: imb-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6191641b5ba51ac297465ad32ec1d509d4b473ffa4cc24ad4bf680668c135002
MD5 1a051252de7dddeeeec855a6f6dc4889
BLAKE2b-256 f7f55ee5de835a0f6e081d473e79fdbef0b4bebc8b42621067a1e04365aa1054

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