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",
    ],
)

predictor = Detector(session, PillowToTensorContainStrategy())
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.1.5.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

yolonnx-0.1.5-py3-none-any.whl (7.8 kB view hashes)

Uploaded Python 3

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