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.

ResNetSession

ResNet inference session for image classification. Performs ImageNet-style classification with softmax probability normalization.

Example

labels := ["tabby cat", "golden retriever", "sports car"];
session := ResNetSession->New("resnet50.onnx");
result := session->Inference(image_bytes, 224, 224, labels);
"Top: {result->GetName()} ({result->GetConfidence()})"->PrintLine();
session->Close();

Operations

Inference #

ResNet image inference

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

Parameters

NameTypeDescription
imageBytewidth width
heightIntimage height
labelsStringclassification labels

Example

labels := ["cat", "dog", "bird"];
session := ResNetSession->New("resnet50.onnx");
image := FileReader->ReadBinaryFile("animal.jpg");
result := session->Inference(image, 224, 224, labels);
"Top class: {$result->GetName()} ({$result->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
modelStringResNet model path

New # constructor

Constructor.

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

Parameters

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