Skip to content

Results and deployment

Inference and edge deployment

How a trained model runs on a small device, and what Float32 and INT8 mean.

On this page

The idea in one minute

Inference is using a trained model on new data. Deployment is putting the model onto the device that will run it. On the edge that device is small: a single-board computer such as a Raspberry Pi, or a board such as the Arduino UNO Q.

Small devices have limited memory and processing power, so three things matter:

WhatMeaningWhy it matters
Model sizeHow much storage the model file needsIt must fit on the device
Memory (RAM)How much working memory inference needsToo much and the device can't run it
LatencyHow long one prediction takesToo slow and you miss events

Float32 and INT8

A model's weights are numbers. PetalEdge saves every trained model in two forms:

PrecisionEach weight usesSizeSpeedAccuracy
Float3232-bit decimal numberLargestSlowerThe original
INT88-bit whole numberAbout 4 times smallerUsually fasterUsually close to Float32, sometimes a little lower

Turning Float32 into INT8 is called quantization. PetalEdge runs some of your training data through the model to choose the best INT8 scale.

A simple example

A Motion model has 58,000 weights.

  • Float32: 58,000 × 4 bytes ≈ 232 KB.
  • INT8: 58,000 × 1 byte ≈ 58 KB.

If the INT8 version scores 94 % and Float32 scores 95 %, INT8 is a good trade: a quarter of the size for one point of accuracy.

What happens on the device

  1. 1New dataImage, sensor window or sound
  2. 2PrepareSame processing as in training
  3. 3ModelRuns the neural network
  4. 4ResultLabel, number or objects
Inference on the device

The data must be prepared exactly as it was during training (same window size, frequency or image size). Otherwise the model sees something it was never trained on.

Where you use this in PetalEdge