DEV Community

Cover image for Someone Squeezed a Generative AI Image Model Onto a $1 RP2350
circuitrocks
circuitrocks

Posted on Originally published at blog.circuit.rocks

Someone Squeezed a Generative AI Image Model Onto a $1 RP2350

Edge AI has meant roughly one thing for the past two years: a Jetson, a Coral stick, or at minimum a Raspberry Pi 5 doing the heavy lifting. The quieter, more interesting work is happening a tier below that, on plain microcontrollers with kilobytes of RAM instead of gigabytes. Wake-word spotters on an nRF52, gesture classifiers reading an MPU6050 over I2C, anomaly detection on a bare Cortex-M0. A developer named Tim just pushed that line a lot further than most people assumed it could go.

Faces generated on a Pico 2

His Pico-Faces project runs a generative image model entirely on the RP2350, the same chip sitting inside the Raspberry Pi Pico 2 and costing about a dollar on its own. It produces 128x128 RGB face images in roughly five seconds on the smaller model, or 10 to 20 seconds on the larger one, depending on settings. No cloud call, no host PC in the loop. The demo rig is a Waveshare RP2350-Plus board wired to a Pimoroni VGA driver so output lands straight on a monitor, but the display is optional; you can pull the finished frames over the RP2350's USB connection instead.

How it fits in 520 KB

The chip gives you 520 KB of SRAM and two Cortex-M33 cores, overclocked here from 150 MHz to 300 MHz. Instead of painting pixels directly, the model works in a compressed 16x16x8 latent space and hands off to a VAE decoder holding about 116,000 parameters (493,000 in the big version). Weights are quantized to INT8 and streamed out of flash by DMA as inference runs, so RAM never holds the whole network. The entire thing, inference engine included, fits in 4 MB of flash. Tim expected a convolutional U-Net to win on hardware this small and found a transformer worked better; he also precomputed his conditioning values into lookup tables to dodge runtime math. Stacked together, the optimisations landed about 15x faster than his first working build.

What to try next

You do not need a diffusion model to steal the useful parts. INT8 quantization and DMA-streaming weights out of flash are the two moves that make almost any model fit on a Pico 2, and both are easier to practise on something small: a gesture classifier on an accelerometer, or a keyword spotter that toggles one GPIO pin. Get the memory budget right on a 20 KB model first, then scale. Tim's full write-up, including the architecture diagrams, is on Hackster.


Originally published on blog.circuit.rocks.

edgeai #tinyml #machinelearning #ai #circuitrocks

Top comments (0)