Guides/Basics/01 Detect objects in an image

Detect objects in an image

1from lynx import LYNX
2
3model = LYNX("lynx-basic")
4results = model("frame.jpg")
5
6for box, score, label in zip(results.boxes.xyxy, results.scores, results.labels):
7 x1, y1, x2, y2 = box
8 print(f"{label}: {score:.2f} at ({x1:.0f}, {y1:.0f}, {x2:.0f}, {y2:.0f})")

Everything else in the SDK builds on this — classify, encode, track, callbacks are all variations on "load a model, call it, read the result".

The session is cached process-wide. Calling LYNX("lynx-basic") twice in one process reuses the loaded model, so you don't need to hoist it into a singleton yourself. First-call latency includes ORT session build + execution-provider load (CoreML / CUDA / DirectML); call model.warmup() before any timing-sensitive path so that cost doesn't land on a real request.

For batch throughput, pass a list or a directory path — model([...]) runs one ORT session across all inputs and returns list[Results]. Per-class thresholds via a dict: conf={"person": 0.5, "car": 0.3, "default": 0.25} lets you tune sensitivity without retraining.

Next
Categorize an image
When the answer you need is "what is this" rather than "where is it".