Object detection on a microjoule budget

How changing the question, rather than shrinking the model, cut the energy of watching water fleas by a factor of 680.

The constraint

Project Robocoenosis builds underwater devices that use living organisms as sensors. They run on microbial fuel cells, so every millijoule decides how often they can look.

Water fleas spin when something in the water stresses them, which makes them a cheap detector for pollutants nobody thought to test for. Watching them needs computer vision on the device itself, because radio does not get out of the water and storing video is not real time. The model I ended up with is small enough that it runs on this page, on your own GPU.

Points, not boxes

A standard detector predicts boxes and classes at several scales, through tens of layers. Water fleas are all about the same size, and only where they are and how they move matters. So the model predicts one heatmap peak per animal, in the style of CenterNet, and everything else a detector carries is thrown away.

Left, what a standard detector predicts; right, what this one predicts: one point per animal and a small offset.

Search, then measure

I sampled five hundred architectures at random, varying depth, input resolution, width and block type, and trained them across a GPU cluster. Each was quantised to eight bits and compiled for the accelerator.

Then every one of them ran on the bench. Estimating energy from the architecture works on a CPU but not on an accelerator, so there was no shortcut past measuring.

A precision power supply wired to a Raspberry Pi 5 with a Hailo-8L accelerator
A Keithley 2280S fed the Raspberry Pi and sampled its current at 100 Hz, triggered over GPIO, with Wi-Fi off and a cool-down between runs.

Two convolutions and a head

The best model on the Pareto front, KEYNAS5-204, is three layers deep: two convolutions and a detection head. It reaches an average precision of 0.948 at 2.2 µJ a frame, and runs at 5,167 frames a second.

ModelEnergy per frameFrames per second
YOLO11-nano1,449 µJ73
KEYNAS5-2042.2 µJ5,167
Measured on a Raspberry Pi 5 with a Hailo-8L.

A few things surprised me. Every model on the Pareto front has five layers or fewer. On the accelerator, speed and energy are almost the same thing. And dropping to four bits saved nothing measurable over eight.

input 192 × 192 × 3 conv 3×3, stride 2 96 × 96 × 48 conv 3×3 96 × 96 × 24 head, conv 3×3 96 × 96 × 3 heatmap, after sigmoid a 3 × 3 max-pool keeps the peaks points, tracked cell, offset and heading KEYNAS5-204: two convolutions and a head. Every cell of the 96 × 96 output scores how likely a flea's centre is there, and where in the cell it sits. No boxes and no classes: the network only says where each animal is. How it moves is what matters. circling: stressed output cell offset point heading frame conv conv head heatmap points stressed ones flagged · 10 s loop
How KEYNAS5-204 turns a frame into points. The network only finds each flea. Following the points from frame to frame gives each one a heading, and an animal that keeps circling is the stress signal the device looks for. Schematic.

Run it here

A model this small doesn’t need an accelerator to be fast. Below, KEYNAS5-204 runs in your browser on frames from the held-out test set, which it never saw in training, or on any image you give it. Everything is computed live, on your machine.

Pick a stage on the line under the image to see what the network holds at that point: the input as the network sees it, any of the 72 feature maps, the three raw outputs of the head, or the decoded points. Hover the image to read the values under the cursor.

Loading the model…

Frame

0.50

Show

Inference

…

Points

#scorexy

Pixels in the original frame. Hover a row, or a point, to match them up.

KEYNAS5-204 running live. The threshold, the overlays and the backend all apply as you change them; timings are the median of repeated runs on this frame.

The whole network is 12,387 numbers, about 50 KB, smaller than most of the photos on this page. There is no inference library. Each layer is one dispatch of a WGSL compute shader, with one GPU thread per output value, each summing a 3×3 window across every input channel. Batch norm was folded into the convolution weights at export, so a layer is just a convolution, a bias and, for the first two, a ReLU. The three dispatches go into a single command buffer, and the 96×96×3 output is copied back to the page.

Nearly all the arithmetic is in the second layer: 95.6 of the 113.5 million multiply-adds a frame, because it maps 48 channels to 24 at the full output resolution. The first layer works at a stride of 2, the only downsampling in the network, and the head is cheap because it has just three outputs.

Decoding is the same as on the device. A sigmoid turns the heatmap into scores, a 3×3 max filter keeps only the local peaks, anything under the threshold is dropped, and each survivor moves by its offset from the corner of its cell to the animal. The histogram shows why the threshold barely matters on most of these frames: a peak is either a flea, close to 1, or texture on the dish and the label, well under 0.5.

On a laptop GPU a frame takes a few milliseconds, including the round trip to the GPU and back. As plain JavaScript on the CPU it takes a hundred or two. On the Hailo-8L it took 0.19.

The code is at github.com/Jex-y/lpcv-project-implementation. Back to Ed Jex.