Skip to main content

This package lets you run your YOLOv8 detection and classification models using ONNXRuntime.

Project description

You Only Look ONNX

This repository is a light weight library to ease the use of ONNX models exported by the Ultralytics YOLOv8 framework.

Example Detector Usage

from pathlib import Path

from onnxruntime import InferenceSession
from PIL import Image

from yolonnx.services import Detector
from yolonnx.to_tensor_strategies import PillowToTensorContainStrategy

model = Path("path/to/file.onnx")
session = InferenceSession(
    model.as_posix(),
    providers=[
        "CUDAExecutionProvider",
        "CPUExecutionProvider",
    ],
)

# For backward compatibility reasons the Yolo8ModelOutputParser is used by default
predictor = Detector(session, PillowToTensorContainStrategy(), ModelOutputParser=Yolo26ModelOutputParser())
img = Image.open("path/to/image.jpg")
print(predictor.run(img))

Example Classifier Usage

from pathlib import Path

from onnxruntime import InferenceSession
from PIL import Image

from yolonnx.services import Classifier
from yolonnx.to_tensor_strategies import PillowToTensorContainStrategy

model = Path("path/to/file.onnx")
session = InferenceSession(
    model.as_posix(),
    providers=[
        "CUDAExecutionProvider",
        "CPUExecutionProvider",
    ],
)

predictor = Classifier(session, PillowToTensorContainStrategy())
img = Image.open("path/to/image.jpg")
print(predictor.run(img))

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

yolonnx-0.4.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

yolonnx-0.4.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file yolonnx-0.4.0.tar.gz.

File metadata

  • Download URL: yolonnx-0.4.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for yolonnx-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3eb42886b48d329b1753836a3a046c91fab9974641db62b868d710a178cfc385
MD5 2f169a30c0650c8cdd7cb19dab0a3e2c
BLAKE2b-256 0e99e7858dd63e527c028dfbf85af0c23fff7bcee93645597df6d0e02cbe3e58

See more details on using hashes here.

File details

Details for the file yolonnx-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: yolonnx-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for yolonnx-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c552aefeb0cbbc575f836fcb96ae5223e416c697b354dc32d6440fae2c03a6f0
MD5 bda6ffd3be57b8eddbae212f253bb54b
BLAKE2b-256 80661e67e5c08d8bb17b43cf279fb39821d3dde33031585207fcfd456ed65391

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