
Make a Pi Trash Classifier with Machine Learning and Lobe
Created by Jen Fox
Last updated on 2020-11-18 06:09:13 PM EST

Overview
The Trash Classifier project, affectionately known as "Where does it go?!", is designed to make throwing
things away faster and more reliable.
This project uses a Machine Learning (ML) model trained in Lobe (https://adafru.it/Ocx), a beginner-friendly
(no code!) ML model builder, to identify whether an object goes in the garbage, recycling, compost, or
hazardous waste. The ML model is loaded onto a Raspberry Pi computer to make it usable wherever you
might find rubbish bins!
This tutorial walks you how to create your own Trash Classifier project on a Raspberry Pi from a Lobe
TensorFlow Lite model in Python3.
Difficulty: Beginner++ (some knowledge w/ circuits and coding is helpful)
Read Time: 10 min
Build Time: 60 - 90 min
© Adafruit Industries https://learn.adafruit.com/lobe-trash-classifier-machine-learning Page 3 of 26

Tools and Materials
Hardware
Raspberry Pi 4 Model B - 2 GB RAM
The Raspberry Pi 4 Model B is the newest Raspberry Pi computer made, and the Pi Foundation knows you
can always make a good thing better! And what could make the Pi 4 better...
$35.00
In Stock
Add to Cart
© Adafruit Industries https://learn.adafruit.com/lobe-trash-classifier-machine-learning Page 4 of 26

Raspberry Pi Camera Board v2 - 8 Megapixels
Snap, snap! The Camera v2 is the new official camera board released by the Raspberry Pi Foundation!The
Raspberry Pi Camera Board v2 is a high quality 8...
$29.95
In Stock
Add to Cart
© Adafruit Industries https://learn.adafruit.com/lobe-trash-classifier-machine-learning Page 5 of 26

Official Raspberry Pi Power Supply 5.1V 3A with USB C
The official Raspberry Pi USB-C power supply is here! And of course, we have 'em in classic Adafruit
black! Super fast with just the right amount of cable length to get your Pi 4...
$7.95
In Stock
SD/MicroSD Memory Card (8 GB SDHC)
Add mega-storage in a jiffy using this 8 GB class 4 micro-SD card. It comes with a SD adapter so you can
use it with any of our shields or adapters. Preformatted to FAT so it works out...
$9.95
In Stock
Add to Cart
Add to Cart
© Adafruit Industries https://learn.adafruit.com/lobe-trash-classifier-machine-learning Page 6 of 26

Half-size breadboard
This is a cute half size breadboard, good for small projects. It's 2.2" x 3.4" (5.5 cm x 8.5 cm) with a
standard double-strip in the middle and two power rails on both...
$5.00
In Stock
1 x Pushbutton
On/Off
1 x LEDs
4 indicator LEDs, 1 status LED (5 total)
1 x 220 Ohm Resistors
Need 6 of 25
1 x Jumper wires
Male-Male
If you choose to solder:
1 JST connector (https://adafru.it/drM), female end only
2 M-to-F jumper wires (https://adafru.it/OcC)
10 F-to-F jumper wires (https://adafru.it/OcD)
Heat Shrink Tubing (https://adafru.it/OcE)
Add to Cart
Out of
Stock
Add to Cart
Add to Cart
Add to Cart
© Adafruit Industries https://learn.adafruit.com/lobe-trash-classifier-machine-learning Page 7 of 26

PCB - Half Perma Proto Board (https://adafru.it/eni)
Enclosure
Project case (e.g. cardboard, wood, or plastic box, approx. 6" x 5" x 4")
0.5" x 0.5" (2cm x 2cm) clear plastic square
E.g. from a plastic food container lid
Velcro
Tools
Wire cutters (https://adafru.it/dxQ)
Soldering iron (https://adafru.it/Clg)
Helping Hands (https://adafru.it/dxR) (optional)
Precision knife (e.g. exacto knife) and cutting mat
Hot melt tool (or other non-conductive glue -- epoxy works great but is permanent)
Software (PC-side)
Lobe (https://adafru.it/Ocx)
WinSCP (https://adafru.it/OcF) (or other SSH file transfer method, can use
CyberDuck (https://adafru.it/OcG) for Mac)
Terminal
Remote Desktop Connection or RealVNC
© Adafruit Industries https://learn.adafruit.com/lobe-trash-classifier-machine-learning Page 8 of 26

Before Starting
This project assumes you're starting with a fully set-up Raspberry Pi in a headless configuration. Here's a
beginner-friendly guide on how to do this. (https://adafru.it/OcH)
It also helps to have some knowledge of the following:
1. Familiarity with the Raspberry Pi
Here's a handy getting started guide! (https://adafru.it/OcI)
Also helpful: Getting started with the Pi camera (https://adafru.it/OcJ)
2. Reading and editing Python code (you won't need to write a program from scratch, just edit)
Introduction to Python with the Raspberry Pi (https://adafru.it/OcK)
3. Reading Fritzing wiring diagrams
4. Using a breadboard
Breadboards for beginners guide (https://adafru.it/OcL)
Find out where your trash goes
Each city across the US (and I would assume the globe) has its own garbage/recycling/compost/etc.
collection system. This means that to make an accurate trash classifier, we'll need to 1) build a custom ML
model (we'll cover this in the next step -- no code!) and 2) know where each piece of trash goes.
Since I didn't always know the proper bin for each item I used to train my model, I used the Seattle Utilities
flyer shown above, and also this handy "Where does it go?" lookup tool (https://adafru.it/OcM) for the city
of Seattle! Check out what resources are available in your city you by looking up your city's garbage
collection utility and perusing its website.
© Adafruit Industries https://learn.adafruit.com/lobe-trash-classifier-machine-learning Page 9 of 26