AI¶
AI runs ONNX models on the appliance through a model-agnostic tensor interface, with client-side helpers that add per-model-family semantics (pre-processing, detection decoding).
Models are *.onnx files in the appliance model directory
(OLO_AI_MODEL_DIR, default /app/models/ai in the appliance image).
The shipped YOLOX weights (yolox_s.onnx, yolox_tiny.onnx,
yolox_nano.onnx) live in apps/appliance/models/ai/ (Git LFS).
Load one by name, then
exchange named tensors; shape and dtype metadata comes from the model itself
via info() (dynamic dimensions are reported as -1).
For object detection, the YoloDetector adapter wraps a
YOLOX model with letterbox pre-processing, output decoding, and non-maximum
suppression, returning standard Detection results whose
boxes plug directly into the vision depth helpers.
AI wrapper over olo.ai.v1.Ai — generic ONNX model inference.
Service
- class olo.ai.Ai[source]¶
Bases:
objectSync wrapper for the AI gRPC service.
- class olo.ai.Model[source]¶
Bases:
objectHandle for a loaded ONNX model session on the appliance.
Types
- class olo.ai.ModelInfo[source]¶
Bases:
objectMetadata for a loaded ONNX model session.
- __init__(model_id, name, inputs, outputs, metadata=<factory>)¶
- Parameters:
model_id (str)
name (str)
inputs (tuple[TensorInfo, ...])
outputs (tuple[TensorInfo, ...])
- Return type:
None
- class olo.ai.TensorInfo[source]¶
Bases:
objectDeclared model input/output; dynamic dimensions are -1.
- class olo.ai.Detection[source]¶
Bases:
objectStandard object-detection result returned by detector adapters.
Fields map 1:1 onto a future olo.ai.v1.Detection wire message. The box is an olo.vision.BoundingBox, so detections feed directly into depth helpers such as sample_depth_region and deproject_region.
- __init__(label, class_id, score, box)¶
- Parameters:
label (str)
class_id (int)
score (float)
box (BoundingBox)
- Return type:
None
Processing helpers
- olo.ai.processing.letterbox(array, size, *, pad_value=114, center=False)[source]¶
Resize an HWC image to (height, width) preserving aspect ratio with padding.
- olo.ai.processing.image_to_tensor(array, *, layout='NCHW', channel_order='BGR', dtype=<class 'numpy.float32'>, scale=None, mean=None, std=None)[source]¶
Convert an HWC BGR image array into a batched model input tensor.
Applies optional value scaling (e.g. 1/255) and per-channel mean/std normalization, then transposes to the requested layout with batch dim 1.
- olo.ai.processing.nms(boxes_xyxy, scores, iou_threshold)[source]¶
Greedy non-maximum suppression; returns kept indices by descending score.
YOLOX adapter
- class olo.ai.yolo.YoloDetector[source]¶
Bases:
objectRuns a YOLOX ONNX model through a loaded Model and decodes detections.
- __init__(model, *, labels=('person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'), input_size=None, strides=(8, 16, 32))[source]¶
Bind to a loaded model; input size is read from the model when static.
- olo.ai.yolo.decode_yolox(raw, input_size, *, strides=(8, 16, 32))[source]¶
Decode raw YOLOX output rows into (N, 5+C) pixel-space predictions.
YOLOX exports emit grid-relative rows (cx, cy, log w, log h, objectness, class scores…). This applies the per-stride grid offsets and exp scaling, yielding center-based boxes in input-image pixels.
Import from olo/ai:
Service
Types
ModelInfo Metadata for a loaded model session.
TensorInfo Declared model input/output.
Tensor Dense tensor backed by a typed array.
Detection Standard object-detection result.
Processing helpers
YOLOX adapter