Skip to main content

Tiny configuration for Triton Inference Server

Project description

tritony - Tiny configuration for Triton Inference Server

Pypi CI Coverage Status

What is this?

If you see the official example, it is really confusing to use where to start.

Use tritony! You will get really short lines of code like example below.

import argparse
import os
from glob import glob
import numpy as np
from PIL import Image

from tritony import InferenceClient


def preprocess(img, dtype=np.float32, h=224, w=224, scaling="INCEPTION"):
    sample_img = img.convert("RGB")

    resized_img = sample_img.resize((w, h), Image.Resampling.BILINEAR)
    resized = np.array(resized_img)
    if resized.ndim == 2:
        resized = resized[:, :, np.newaxis]

    scaled = (resized / 127.5) - 1
    ordered = np.transpose(scaled, (2, 0, 1))
    
    return ordered.astype(dtype)


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--image_folder", type=str, help="Input folder.")
    FLAGS = parser.parse_args()

    client = InferenceClient.create_with("densenet_onnx", "0.0.0.0:8001", input_dims=3, protocol="grpc")
    client.output_kwargs = {"class_count": 1}

    image_data = []
    for filename in glob(os.path.join(FLAGS.image_folder, "*")):
        image_data.append(preprocess(Image.open(filename)))

    result = client(np.asarray(image_data))

    for output in result:
        max_value, arg_max, class_name = output[0].decode("utf-8").split(":")
        print(f"{max_value} ({arg_max}) = {class_name}")

Release Notes

  • 23.06.16 Support tritonclient>=2.34.0
  • Loosely modified the requirements related to tritonclient

Key Features

  • Simple configuration. Only $host:$port and $model_name are required.
  • Generating asynchronous requests with asyncio.Queue
  • Simple Model switching
  • Support async tritonclient

Requirements

$ pip install tritonclient[all]

Install

$ pip install tritony

Test

With Triton

docker run --rm \
    -v ${PWD}:/models \
    nvcr.io/nvidia/tritonserver:22.01-pyt-python-py3 \
    tritonserver --model-repo=/models
pytest -m -s tests/test_tritony.py

Example with image_client.py

# Download Images from https://github.com/triton-inference-server/server.git
python ./example/image_client.py --image_folder "./server/qa/images"

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

tritony-0.0.12rc0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

tritony-0.0.12rc0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file tritony-0.0.12rc0.tar.gz.

File metadata

  • Download URL: tritony-0.0.12rc0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for tritony-0.0.12rc0.tar.gz
Algorithm Hash digest
SHA256 b79140cb6bc91da8db5412b551f515c6744536c63fa1d0c82e2e6ed8d9698fa9
MD5 7d7f10b5ef4ddb86f0cf58461492a302
BLAKE2b-256 fb98dec7f2bd405bbfceeef3360b1d1fa1729009cea7f1881782f33593a0075f

See more details on using hashes here.

File details

Details for the file tritony-0.0.12rc0-py3-none-any.whl.

File metadata

  • Download URL: tritony-0.0.12rc0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for tritony-0.0.12rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f7268b593efe2a761b808254d606323b879c250f0608d15bd3fca1d3d08ac03
MD5 9242253cf96b7762de45d34877e747de
BLAKE2b-256 96282e0fca8066186306ca2d34404949fd5f76932d41efb98f182cf2ce7adfd7

See more details on using hashes here.

Supported by

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