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.3.0.tar.gz (5.1 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.3.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yolonnx-0.3.0.tar.gz
  • Upload date:
  • Size: 5.1 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.3.0.tar.gz
Algorithm Hash digest
SHA256 2561f2f0f795d96a0bf4830bbf4f3fb3dc67e8475c1d79ee54f1e7ae57d3bab9
MD5 4865b3b361add7952980747cd5817541
BLAKE2b-256 0373233cc7f3e7d9972a12bf7f345eee27b1f807ff72e75e72b4874372f5408f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yolonnx-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 696e1dd08822fb9d5f800dff978b6777200239d78c8e1d4aef76a100fdf94393
MD5 933194941104b23a4439b34170f8fadd
BLAKE2b-256 faae7e7db6a98339561e04f0a046a99778aae23e5f6c35de5805fc70a65d8008

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