Skip to main content

⚡ TRISM Inference Client

Perform batch inference on models deployed in a Triton Inference Server using a Python client.


Introduction

TritonModel supports: - Connecting to Triton Server (gRPC or HTTP)

  • Multi-input and multi-output models
  • Automatic batching and data stacking
  • Auto-generating config.pbtxt based on model metadata from Triton

Input Data Structure

The input passed to the run() function is a dict:

data = {
    "input_name_1": [array1, array2, ...],
    "input_name_2": [array1, array2, ...],
}
  • Key: must match the input name defined on the Triton Server.
  • Value: a list of tensors with the same shape (already padded but not stacked). The client will automatically stack, split into batches, and send to the server.

Example Usage

from trism_cv import TritonModel
import numpy as np

# Initialize client & run inference
model = TritonModel(model="model_name", version=1, url="# Triton server address", grpc=True)

# --- Case 1: Batched input ---
# data is a list of images with the same shape (HxWx3)
batched_data = [np.random.rand(640,640,3).astype(np.uint8)] * 3
outputs_batched = model.run({"INPUT": batched_data}, auto_config=True, batch_size=2) #batch_size default=2, can be customized
print("Batched output:", outputs_batched)


# --- Case 2: No batch ---
single_data = [np.random.rand(640, 640, 3).astype(np.float32)]  
outputs_single = model.run({"INPUT": single_data}, auto_config=True, batch_size=1) 
print("Single output:", outputs_single)

Output Format

The TritonModel.run() method can return 4 different formats depending on the model:

Output Type Format Notes
Single-output list[np.ndarray] Each element = output of one input sample
Length = number of input samples.
Multi-output dict[str, list[np.ndarray]] Each key = output name
Each value = list of per-sample outputs
Length = number of input samples.

Example of how to handle the output:

# Single-output
for i, sample in enumerate(outputs):
    print(f"Sample {i} shape:", sample.shape)

# Multi-output
for name, samples in outputs.items():
    for i, sample in enumerate(samples):
        print(f"{name} - sample {i}: shape={sample.shape}")

Auto Configuration (config.pbtxt)

TritonModel can automatically generate the config.pbtxt file by reading metadata from the Triton Server. This helps users:

  • Avoid writing input/output configuration manually
  • Ensure compatibility with the server's model definition

Environment Requirements

  • Python >= 3.9
  • opencv-python
  • numpy
  • tqdm
  • tritonclient
  • trism_cv (custom module)

Quick installation:

pip install opencv-python numpy tqdm tritonclient[grpc]

Notes

  • All inputs must have the same shape for batching.
  • Input keys must match those defined on Triton.
  • The model must be in READY state on the server.
  • Multiple batches can be processed in parallel to increase throughput.

License

GNU AGPL v3.0.
Copyright © 2025 Tien Nguyen Van. All rights reserved.

Metadata

Release files for trism-cv 0.1.1.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trism-cv 0.1.1.post1
File Size Uploaded
trism_cv-0.1.1.post1.tar.gz 22.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trism-cv 0.1.1.post1
File Interpreter ABI Platform
trism_cv-0.1.1.post1-py3-none-any.whl Python 3 none any Details

Total release size: 46.6 kB

Release files / trism_cv-0.1.1.post1.tar.gz

Download URL trism_cv-0.1.1.post1.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
41a5bafd2a67ec427cf7cc0d4fdbd1b6328eb6814e345b320da11e5b4d7411f8
BLAKE2b-256 checksum
How to use checksums
1b590c586ea2d5d0db7723e024b97194dbab4c7666d13a98dc1bdc571975d66a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.0

Release files / trism_cv-0.1.1.post1-py3-none-any.whl

Download URL trism_cv-0.1.1.post1-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81b82800a11bcd55eedda455cafe5318856c4fec4b3a14edc5950d6b1bdd3b78
BLAKE2b-256 checksum
How to use checksums
f7dff2b679af857ab64c123d315de78763d6b7dcc92461ef0e754b7596f479bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.0

Release history Release notifications | RSS feed

This release

0.1.1.post1 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page