<!--
SPDX-FileCopyrightText: 2026 James Harton

SPDX-License-Identifier: Apache-2.0
-->

<img src="https://github.com/beam-bots/bb/blob/main/logos/beam_bots_logo.png?raw=true" alt="Beam Bots Logo" width="250" />

# bb_estimator_yolo

[![CI](https://github.com/beam-bots/bb_estimator_yolo/actions/workflows/ci.yml/badge.svg)](https://github.com/beam-bots/bb_estimator_yolo/actions/workflows/ci.yml)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache--2.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
[![Hex version badge](https://img.shields.io/hexpm/v/bb_estimator_yolo.svg)](https://hex.pm/packages/bb_estimator_yolo)
[![Hexdocs badge](https://img.shields.io/badge/docs-hexdocs-purple)](https://hexdocs.pm/bb_estimator_yolo)
[![REUSE status](https://api.reuse.software/badge/github.com/beam-bots/bb_estimator_yolo)](https://api.reuse.software/info/github.com/beam-bots/bb_estimator_yolo)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/beam-bots/bb_estimator_yolo)

[`bb_inference`](https://github.com/beam-bots/bb_inference) model codecs
for YOLO-family object detectors, for use with
[`bb_estimator_object_detection`](https://github.com/beam-bots/bb_estimator_object_detection).

```elixir
inference do
  model :detector do
    runtime BB.Inference.OpenCV
    source "https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_nano.onnx"
    sha256 "c789161ed43c8269fcd4e67c67eeeb4e80c622da2eb296a20bc6007bd18a0b7d"
    codec BB.Estimator.Yolo.YoloX
  end
end

topology do
  link :head do
    sensor :camera, {BB.Camera.V4L, device: "/dev/video0"} do
      estimator :objects, {BB.Estimator.ObjectDetection, model: :detector}
    end
  end
end
```

## Codecs

| Codec | For | Checked against |
|---|---|---|
| `BB.Estimator.Yolo.YoloX` | YOLOX exported without its decode step | Megvii's `yolox_nano.onnx` on OpenCV; PINTO's float32 TFLite YOLOX-nano on TFLite |

A codec is only shipped once it has been run against a real artefact and
produced the right boxes.

The codec's defaults are Megvii's conventions (BGR, 0-255, letterboxed into
the top left on grey 114). Other conversions of the same network differ, and
say so in the model's `codec` options - PINTO's TFLite conversion takes RGB
with ImageNet's normalisation:

```elixir
codec {BB.Estimator.Yolo.YoloX,
       colour: :rgb, mean: {123.675, 116.28, 103.53}, std: {58.395, 57.12, 57.375}}
```

## Installation

```bash
mix igniter.install bb_estimator_yolo
```
