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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file imb-1.0.3.tar.gz.
File metadata
- Download URL: imb-1.0.3.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7f3842756d72786b519fa4714fe25e710fe377386c66aed179ec38b400b8bed
|
|
| MD5 |
5ebbdb80e4a45414f3c42aa6bd7da5d3
|
|
| BLAKE2b-256 |
c17e5852d785e29f6c964bada4ed6688e1e642b5898ee10b8d3722ddcd7cb211
|
File details
Details for the file imb-1.0.3-py3-none-any.whl.
File metadata
- Download URL: imb-1.0.3-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b5aca89b7bd4117477d3f5ea4a09dd3f7e7f8dee199807c4cc51bbae42a7991
|
|
| MD5 |
c68eb17f93a70433562a0d979b0ddf8f
|
|
| BLAKE2b-256 |
d5ff457128f1893babb08c7635c8d06506293508e2d99bea332471858fbd9fca
|