AI-generated Old site ↗
← All projects
03 CMU · Edge AI
Waste classifier running on a Raspberry Pi 5

Waste Classification on a Raspberry Pi 5

2024
Lede

Vision classifier squeezed onto a Pi 5 to run offline. The constraints ended up being more interesting than the model.


Approach

Three architectures, a lot of ablations.

Optimized CNNs for waste classification by running ablation studies across data augmentation, model architecture, and dataset size — with practical deployment as the constant constraint. Trained three architectures on TrashNet to compare. The ablation results ended up dictating most of the training transforms and downstream decisions: which transforms were on the train pipeline mattered more than swapping between architectures of similar capacity.

Deployment

Getting the model onto the Pi was the project.

INT8 quantization broke parts of the network on the first try, so re-training with quantization-aware tweaks recovered most of the accuracy. Under sustained inference the Pi 5 thermal-throttled, which dropped throughput in a way that bench testing missed. And the cheap CSI camera produced images with subtly different statistics than the training set, so a light on-device color/contrast normalization step closed the gap.

Takeaway

Edge ML is plumbing, not architecture.

On the Pi, the model was almost a fixed-cost line item. The cost of moving was elsewhere: the camera pipeline, the quantization fallout, the heatsink. A useful reminder for anyone treating 'put a model on the edge' as a model problem.

Detail

Set out to build a small camera-based waste sorter that could run without a network connection. The model isn't the interesting part, the constraints are. Throttling under thermal load, INT8 quantization that broke parts of the network on first try, the slightly different image statistics from a cheap CSI camera. The takeaway: most of the work in a deployment-first ML project is not actually the model.

Gallery
Hardware stack and on-device demos
Hardware stack + classifier demos on the Pi 5.
Software stack
Software pipeline from camera capture through quantized ONNX inference.
Ablation results across three CNN architectures
Ablation results across three CNN architectures, used to pick the deployment model.
Stack
  • ONNX
  • Raspberry Pi 5
  • OpenCV
  • INT8 quantization
  • TrashNet