v2026.10.0
All Bundles
Bundle

ONNX Runtime inference library for running pre-trained models. Supports object detection (YOLO), image classification (ResNet), segmentation (DeepLab), pose estimation (OpenPose), face recognition, and Phi-3 text generation. Compile with -lib onnx.

YoloSession

YOLO inference session for object detection (v8 and above). Supports YOLO11/YOLO12 with fused head, letterbox preprocessing, and automatic FP16/FP32 input handling.

Example

labels := ["person", "bicycle", "car"];
session := YoloSession->New("yolo11n.onnx");
result := session->Inference(image_bytes, 640, 640, 0.5, labels);
each(cls in result->GetClassifications()) {
  "{cls->GetName()}: {cls->GetConfidence()}"->PrintLine();
};
session->Close();

Operations

Inference #

Yolo image inference, support for models v8 and above

method : public : Inference(image:Byte[], height:Int, conf_threshold:Float, labels:String[]) ~ API.Onnx.YoloResult

Parameters

NameTypeDescription
imageBytewidth width
heightIntimage height
conf_thresholdFloatconfidence threshold
labelsStringclassification labels

Example

labels := ["person", "car", "dog"];
session := YoloSession->New("yolo11n.onnx");
image := FileReader->ReadBinaryFile("photo.jpg");
result := session->Inference(image, 640, 640, 0.5, labels);
each(cls in result->GetClassifications()) {
  "{$cls->GetName()}: {$cls->GetConfidence()}"->PrintLine();
};
session->Close();

IsOpen #

Whether the model loaded. A session that failed to open is not an error at construction -- the constructor returns an object either way, and the reason was written to stderr while it happened. Test this before inferring: a closed session returns Nil from every inference method, which is otherwise indistinguishable from a model that found nothing.

method : public : IsOpen() ~ Bool

Return

TypeDescription
Booltrue when the model is loaded and inference can run

New # constructor

Constructor.

New(model:String)

Parameters

NameTypeDescription
modelStringYOLO model path

New # constructor

Constructor.

New(model:String, config:Map<String,String>)

Parameters

NameTypeDescription
modelStringYOLO model path
configMap<String,String>session configuration parameters