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.
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.
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.
| Model | Energy per frame | Frames per second |
|---|---|---|
| YOLO11-nano | 1,449 µJ | 73 |
| KEYNAS5-204 | 2.2 µJ | 5,167 |
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.
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
Show
Inference
…
Points
| # | score | x | y |
|---|
Pixels in the original frame. Hover a row, or a point, to match them up.
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.