Skip to content

celtera/avendish-ml-processor-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Avendish ML / ONNX inference template

A canonical template for making ONNX inference objects with Avendish: a single C++ object that runs a .onnx model with onnxruntime and is compiled, without rewrite, to the host formats that have a real object model.

It is the ML counterpart of the audio, video, geometry and data templates.

What gets built

avnd_make_object(...) instantiates the object back-ends — not the audio plug-in formats (VST3 / CLAP):

Back-end SDK required
Max/MSP, Pure Data Max SDK, PureData headers
TouchDesigner (CHOP message) TouchDesigner Custom Operator SDK
Godot (GDExtension node) none — fetched by CMake
Python (extension module) pybind11
ossia score libossia

onnxruntime is downloaded by CMake (cmake/onnxruntime.cmake, the prebuilt CPU release) and linked into every back-end. Avendish has no ONNX helper, so the object uses the onnxruntime C++ API directly; for richer (vision) models see ossia/score-addon-onnx.

The object

src/Model.hpp implements MyOnnxProcessor: set Model to a .onnx path, feed a float vector on Input, and it runs the model's single input/output and emits the result on Output. The session is (re)loaded when the path changes.

A tiny model is bundled: model/scale_by_two.onnx computes y = 2*x (so [1,2,3][2,4,6]). Regenerate / replace it with your own; change the ports in Model.hpp to match your model's shapes.

Building

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build

CMake downloads onnxruntime and godot-cpp automatically. Pass -DAVND_MAXSDK_PATH=…, -DTOUCHDESIGNER_SDK_PATH=…, -DCMAKE_INCLUDE_PATH=…/pure-data/src, -Dpybind11_DIR=… to enable the other back-ends — see the Github actions workflow (shared ossia/actions/avendish-template action).

Notes

  • onnxruntime's C++ API is compiled with ORT_NO_EXCEPTIONS to match Avendish's -fno-exceptions build; model/inference errors therefore abort rather than throw, so feed valid models and shapes.
  • At runtime each plug-in needs the onnxruntime shared library next to it (it is fetched into the build tree under _deps/onnxruntime-src/lib).

About

Template for ONNX inference objects with Avendish + onnxruntime — Max, Pd, TouchDesigner, Godot, Python, ossia

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors