Generic inference module powered by ONNX Runtime. Loads any .onnx model file, reads its port layout from an optional model-description.md companion file, and maps model inputs/outputs to Usine ports in real time using a dedicated background worker thread.
ONNX (Open Neural Network Exchange) is an open format for machine-learning models. Models trained in PyTorch, TensorFlow, scikit-learn, or any compatible framework can be exported to
.onnxand run directly in Usine without any Python runtime. The module handles all type conversions between Usine flow types and the flat float tensors expected by the model.
File path to the .onnx model file. Click to open a file browser filtered to *.onnx. When a file is selected, the module:
model-description.md file in the same directory as the .onnx file.The model is reloaded automatically when the threads setting changes.
Number of CPU threads allocated to ONNX Runtime's intra-op parallelism. Range 1 – 8, default 1. Increase for large models or on multi-core systems; for small models a single thread usually gives lower latency.
The module provides 2 input ports (input-0, input-1). Their captions and flow types are set automatically when a model is loaded.
| Port state | Meaning |
|---|---|
| not used | No model loaded, or the model has fewer inputs than this slot. |
| port name from model | Configured by the model-description.md frontmatter. |
Port flow types depend on the flow field in the model description:
| Flow type | Usine type | Notes |
|---|---|---|
array |
FT_ARRAY | Default. Float array of fixed size. |
data |
FT_DATA_FLOAT | Single float value (size always 1). |
audio |
FT_AUDIO | Audio signal. Automatic resampling and windowing. See Audio ports below. |
video |
FT_VIDEO | Video frame. Automatic resize and pixel-to-float conversion. See Video ports below. |
The module provides 5 output ports (output-0 to output-4). Their captions and flow types are configured by the model description, following the same rules as inputs.
Inference latency in milliseconds, measured from the moment inputs are submitted to the worker thread until the result is written back. Useful for performance profiling.
Place a file named model-description.md next to your .onnx file to control port layout, captions, and flow types. Without this file the module still works but all ports default to array flow and use the raw ONNX tensor names as captions.
The file uses a YAML frontmatter block (between --- markers). Any text after the second --- is loaded as the model description and shown in the module's Properties panel.
---
usine:
version: 1
name: "My Model"
description: "Short description shown in Properties."
inputs:
- name: input_tensor_name # must match the ONNX tensor name exactly
label: "friendly caption" # optional, shown on the port
flow: array # array | data | audio | video
size: 128 # number of float elements
outputs:
- name: output_tensor_name
label: "result"
flow: data
---
Longer description shown in the Properties panel.
When flow: audio, additional fields control windowing and resampling:
| Field | Description |
|---|---|
size |
Window size in model samples (e.g. 16000 for 1 s at 16 kHz). |
sample_rate |
Model sample rate in Hz. Usine resamples from its own sample rate automatically. |
hop |
Hop size in model samples. When set, a new inference is triggered every hop samples rather than every size samples (overlapping windows). If omitted, defaults to size (no overlap). |
normalize |
Normalization applied before submitting to the model. Currently supported: zero-mean-unit-variance. |
inputs:
- name: audio_input
label: "microphone"
flow: audio
size: 16000 # 1 s window at 16 kHz
sample_rate: 16000
hop: 8000 # inference every 0.5 s (50% overlap)
normalize: zero-mean-unit-variance
When flow: video, the input frame is resized to the model's expected resolution and converted to a flat float tensor in [0, 1]:
| Field | Description |
|---|---|
width |
Expected frame width in pixels. |
height |
Expected frame height in pixels. |
channels |
Number of color channels: 1 (grayscale), 3 (RGB), or 4 (RGBA). |
format |
Tensor layout: chw (channels-first) or hwc (channels-last, default). |
inputs:
- name: image
label: "camera"
flow: video
width: 224
height: 224
channels: 3
format: chw # PyTorch convention
Usine Process thread Background worker thread
───────────────────── ─────────────────────────
[input data ready]
→ copy to worker buffer
→ signal worker
← wake up
← run ONNX session
← write outputs to buffer
[next process cycle]
→ check HasOutput
→ copy outputs to ports
→ write InferenceTime
The worker thread runs asynchronously: the Process thread never blocks. If inference is slower than the process block rate, the module silently skips frames. This ensures Usine's audio engine is never stalled.
For audio ports, samples are written into a ring buffer as they arrive. When the ring buffer has accumulated enough samples to fill one window:
hop samples later.Output audio is upsampled back to Usine's sample rate after inference.
If the incoming frame dimensions differ from the model's expected width × height, the frame is rescaled using a fast low-quality resize on the worker thread. Pixel values are converted to [0, 1] floats (dividing by 255). Channel ordering follows the format field.
1. Export your model to ONNX
From PyTorch:
torch.onnx.export(model, dummy_input, "my_model.onnx",
input_names=["features"],
output_names=["label_scores"])
2. Write a model-description.md
Create model-description.md next to my_model.onnx:
---
usine:
version: 1
name: "My Classifier"
inputs:
- name: features
flow: array
size: 32
outputs:
- name: label_scores
flow: array
size: 10
---
Classifies a 32-element feature vector into 10 categories.
3. Load in Usine
my_model.onnx.4. Monitor
Port captions and flow types are set at load time. Changing the model file reconfigures all ports immediately. Wires connected to ports whose flow type changes will be disconnected automatically.
The maximum number of inputs is 2 and the maximum number of outputs is 5. If your model has more tensors, only the first ones (up to the limit) will be exposed.
If no model-description.md is found, all ports default to array flow using the raw ONNX tensor names. This is sufficient for simple array-to-array models.
Audio input ports accumulate samples across process blocks. There is an inherent latency equal to one window size at minimum. For real-time audio processing, prefer small window sizes and use hop to control the inference rate.
Button. Opens the manual page of the selected object (or of its parent module for a control) in the web browser. If no page exists for this object, an error is traced in the trace panel.
For more details about information/help creation, see create-help-file.
Free multi-line text attached to the module, saved with the patch. It is only meant as an internal note for the patch designer: it is not displayed in the interface.
visible only in god mode, see setup-panel-tab-expert.
Read-only, not saved. Current private numeric ID of the object, used internally to identify it (for example as the target of a bind ID).
Read-only, not saved. Private ID used to store and recall the values of this control in presets.
Button. Generates a new unique ID, original ID and preset ID for the object. Use it if you experience difficulties in Polyphonic mode or if two objects share the same ID. Preset values and binds referring to the old IDs are lost.
Read-only, not saved. Absolute address of the object in the Usine objects tree, built from the workspace root. This is the address to use to reach the object from scripts, the objects panel or remote messages. Only shown for objects that are registered in the objects list. See objects-address.
Read-only, not saved. Address of the object relative to the current patch, valid inside that patch only. See objects-address.
Free user-defined address for the object (empty by default). When set, the object is also registered in the objects tree under this name, so it can be reached independently of its position in the workspace (the value is also reported in the mouse-over and mouse-down chunks). Changing it rebuilds the objects list. Only available on objects that support a user address. See objects-address.
version 7.0.250121
Edit All Pages