#inference #onnx #lua-bindings #lua #tensorflow

mlua-tract

Lua bindings for tract, the tiny, no-nonsense, self-contained, Rust-based Tensorflow and ONNX inference runtime

3 releases

0.1.2 Feb 17, 2024
0.1.1 Jan 13, 2024
0.1.0 Jan 7, 2024

#719 in Machine learning

MIT license

95KB
986 lines

mlua-tract

Lua bindings for tract, the tiny, no-nonsense, self-contained, Rust-based Tensorflow and ONNX inference runtime.

License Arch Lua

Installing

Add to your Rust project using one of MLua's features: [lua51, lua52, lua53, lua54, luajit, luajit52].

$ cargo add mlua-tract --features luajit

Using

use mlua::Lua;
use mlua_tract;

let lua = Lua::new();
mlua_tract::preload(&lua)?;
let script = r#"
    local tract_onnx = require('tract.onnx')
    local model = tract_onnx.model_for_path('testdata/keras-tract-tf2-example.onnx')
    return tostring(model:input_fact(1))
"#;
let result: String = lua.load(script).eval()?; // returns: "unk__6,100,F32"

Testing

$ make check

Dependencies

~19–32MB
~530K SLoC