# `BB.Estimator.Yolo.YoloX`
[🔗](https://github.com/beam-bots/bb_estimator_yolo/blob/main/lib/bb/estimator/yolo/yolox.ex#L5)

A codec for YOLOX exported without its decode step, as Megvii publish it.

    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

## The model

One image input, `{1, 3, H, W}` or `{1, H, W, 3}`, and one output of
`{1, anchors, 5 + classes}`, where `anchors` is
`H/8·W/8 + H/16·W/16 + H/32·W/32`: one row per cell of the stride 8, 16
and 32 grids, each `{x, y, log w, log h, objectness, class scores...}`,
grid-relative, with objectness and class scores already through a sigmoid.
The output may be quantised; only the values read are dequantised, and
most rows are rejected on objectness alone.

The candidates overlap, so the estimator suppresses them.

## Input conventions

The defaults are Megvii's: BGR pixels from 0 to 255, letterboxed into the
top-left corner and padded with grey 114. Conversions by others differ.
PINTO's TFLite conversion of YOLOX-nano, for instance, takes RGB normalised
with ImageNet's mean and standard deviation:

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

## Options

* `:colour` - The channel order the model takes. Valid values are :rgb, :bgr The default value is `:bgr`.

* `:resize` - `:stretch` to fill the model's input, ignoring the aspect ratio, or
  `:letterbox` to fit it, keeping the aspect ratio and padding the rest.
   Valid values are :stretch, :letterbox The default value is `:letterbox`.

* `:letterbox_align` - Where a letterboxed image sits in the model's input. Valid values are :top_left, :centre The default value is `:top_left`.

* `:pad` - The grey level letterbox padding is filled with. Valid values are between 0 and 255 The default value is `114`.

* `:mean` - Subtracted from each channel before dividing by `:std`: one number,
  or `{c1, c2, c3}` in the model's channel order. The default value is `0.0`.

* `:std` - Each channel is divided by this after subtracting `:mean`: one
  number, or `{c1, c2, c3}` in the model's channel order. The default value is `1.0`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
