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.
DeepLabSession
DeepLab inference session for semantic segmentation. Auto-detects model input dimensions and supports both NCHW and NHWC layouts. Returns per-class coverage percentages and polygon boundaries.
Example
labels := ["background", "person", "bicycle", "car"];
session := DeepLabSession->New("deeplabv3.onnx");
result := session->Inference(image_bytes, labels);
each(cls in result->GetClassifications()) {
"{cls->GetName()}: {cls->GetConfidence()}%"->PrintLine();
};
session->Close();Operations
Inference #
DeepLab image inference
method : public : Inference(image:Byte[], labels:String[]) ~ API.Onnx.DeepLabResultParameters
| Name | Type | Description |
|---|---|---|
| image | Byte | width width |
| labels | String | classification labels |
Example
labels := ["background", "person", "car"];
session := DeepLabSession->New("deeplabv3.onnx");
image := FileReader->ReadBinaryFile("scene.jpg");
result := session->Inference(image, 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() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true when the model is loaded and inference can run |