sonos/tract

Public

Tiny, no-nonsense, self-contained, Tensorflow and ONNX inference

  • Stars3.1k+11 tuần này
  • Forks298
  • Watchers39
  • Issues75
  • Ngày tạo07/08/2017
  • Cập nhật gần nhất30/10/2026
  • Ngôn ngữRust
  • Giấy phép—
README.md18.9 KBRaw

tract-logo

Rust rustc >= 1.91.0 MIT/Apache 2 Native Linux test status Embedded targets status Doc Python

Sonos' neural-network inference engine.

tract loads ONNX and NNEF models, optimises them, and runs them anywhere — from embedded ARM CPUs to NVIDIA / Apple GPUs, in the browser via WebAssembly, or on a Linux / macOS / Windows workstation. It is used in production at Sonos for wake-word and streaming speech-recognition workloads, and also runs LLM, text-to-image, and classical CV models with a particular focus on the translate-once / ship-tiny-runtime story enabled by its NNEF-based intermediate format (tract-OPL).

Quick start

From examples/onnx-mobilenet-v2:

use tract::prelude::*;
tract::impl_ndarray_interop!();

let model = tract::onnx()?
    .load("mobilenetv2-7.onnx")?
    .into_model()?;

// prepare() optimises and compiles the model for the chosen runtime
let runtime = tract::runtime_for_name("default")?;
let runnable = runtime.prepare(model)?;

let result = runnable.run([input.tract()?])?;

The tract crate (api/rs/src/lib.rs) is the authoritative public API. The internal crates (tract-core, tract-nnef, tract-onnx, ...) are not stable surface and shouldn't be depended on directly.

For Python, see the tract package on PyPI.

Examples

examples/ has runnable demos covering the workloads tract targets today:

Example What
onnx-mobilenet-v2 Minimal CV starter
tflite-mobilenet-v3 TFLite import path
causal_llm Transformer text generation
nemo-parakeet-asr / nemo-nemotron-streaming-asr Speech recognition, including streaming via pulsification
stable-diffusion / stable-diffusion-3 / stable-diffusion-xl Text-to-image
face_detection_yolov8onnx_example / face_similarity_arcface_onnx Modern object detection / face recognition
wasm-model-bench Running tract in the browser

Resources

Technical documentation lives under doc/ (start at doc/intro.md); the doc/cli-recipe.md page collects practical CLI recipes. The Sonos engineering blog has a long-form post on tract internals.

Python

tract is also available as the tract package on PyPI, built on top of the same Rust core:

Nội dung README thuộc về sonos và cộng đồng đóng góp, giấy phép Không có giấy phép. Nguồn: github.com/sonos/tract