Packages

A BB.Inference runtime that runs TensorFlow Lite models through tflite_elixir.

Current section

Files

Jump to
Raw

README.md

<!--
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_inference_tflite

[![CI](https://github.com/beam-bots/bb_inference_tflite/actions/workflows/ci.yml/badge.svg)](https://github.com/beam-bots/bb_inference_tflite/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_inference_tflite.svg)](https://hex.pm/packages/bb_inference_tflite)
[![Hexdocs badge](https://img.shields.io/badge/docs-hexdocs-purple)](https://hexdocs.pm/bb_inference_tflite)
[![REUSE status](https://api.reuse.software/badge/github.com/beam-bots/bb_inference_tflite)](https://api.reuse.software/info/github.com/beam-bots/bb_inference_tflite)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/beam-bots/bb_inference_tflite)

A [`bb_inference`](https://github.com/beam-bots/bb_inference) runtime that
runs TensorFlow Lite models through
[tflite_elixir](https://hex.pm/packages/tflite_elixir).

```elixir
inference do
  model :detector do
    runtime BB.Inference.TFLite
    source "https://storage.googleapis.com/download.tensorflow.org/models/tflite/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip"
    archive_member "detect.tflite"
    sha256 "e4b118e5e4531945de2e659742c7c590f7536f8d0ed26d135abcfe83b4779d13"
    codec {BB.Estimator.ObjectDetection.FinalDetections, mean: 127.5, std: 127.5}
  end
end
```

## Quantised models

Raw values pass straight through. `describe/1` reports each tensor's raw type
and its scale and zero point - per tensor, or per axis with the axis - and
`run/2` takes and returns tensors of exactly those types, refusing an input
of the wrong type rather than reinterpreting its bytes. The model's codec
quantises and dequantises.

Layout is always `nil`: TFLite tensors carry none.

## Options

- `:threads` - interpreter threads; defaults to the number of online
  schedulers

## Installation

```elixir
def deps do
  [
    {:bb_inference_tflite, "~> 0.1.0"}
  ]
end
```