Adafruit Build an ML Package Detector with Lobe Instruction Manual

Build an ML Package Detector with Lobe
Created by Adi Azulay
Last updated on 2021-04-26 06:22:36 PM EDT
2 3
3
4 5
5 5
6 7
7 7
9
9
11
13 15 16
16 16
17
17 20 22
24 27
Guide Contents Overview
Background Knowledge
Required Parts Set up your Pi
Hardware Setup Installing Lobe SDK
Download the Code Set up an FTP Connection
Windows Instructions Mac Instructions
Collect Images
Install your Pi with the Camera pointing towards a package drop-off spot. Collect training images
Train your Model Export your Model Get Predictions on the Pi
Uploading the model to the Pi Run the Package Detector Code
Set up E-mail Alerts
Set up an IFTTT Applet Setup Webhook Key Start the program again
Continuous Learning Going Further
© Adafruit Industries https://learn.adafruit.com/build-an-ml-package-detector Page 2 of 28
Overview
Build a machine learning (ML) package detector that sends you a notification when a package is left at
your door!
You can also use this tutorial to train a model to notify you for any kind of event. For example, lets you
know when your dog is at the door, your favorite parking spot is open, or if there are birds at your bird
feeder.
We'll use Lobe to train our model and then deploy it to a Raspberry Pi 4. We'll use the BrainCraft HAT to
interface with the Pi to collect images and preview what the camera is seeing. Next, we'll setup an applet
on If This Then That to send us an e-mail alert whenever a package is detected. Finally, we'll improve our
model by collecting more training data in situations where the model gets confused.
This tutorial is part of a series which includes:
Tutorial 1: Machine Learning 101 with Lobe and Raspberry Pi (https://adafru.it/Rie)
Tutorial 2: Build an ML Rock Paper Scissors Game with Lobe (https://adafru.it/RiB)
Background Knowledge
New to Lobe? At a minimum, we recommend following the introductory Tutorial 1 above.
To be successful with this project, you'll need some experience with the following:
1. Setting up and using the Raspberry Pi
2. Some familiarity with using the terminal window
3. Installing the Pi Camera
© Adafruit Industries https://learn.adafruit.com/build-an-ml-package-detector Page 3 of 28
Required Parts
Microsoft Machine Learning Kit for Lobe with Raspberry Pi 4 4GB
Machine learning is a transformative tool that’s redefining how we build software—but up until now, it was
only accessible to a small group of experts. At Adafruit, we...
Out of Stock
Out of
Stock
© Adafruit Industries https://learn.adafruit.com/build-an-ml-package-detector Page 4 of 28
Set up your Pi
Hardware Setup
Before starting, set up your Pi and BrainCraft HAT. Follow this primary guide for the
BrainCraft (https://adafru.it/Rta) to configure these services:
Blinka
Fan Service
Display Module
Installing Lobe SDK
Connect to your Pi using SSH and run the following script to install the Lobe SDK:
cd ~ wget https://raw.githubusercontent.com/lobe/lobe-python/master/scripts/lobe-rpi-install.sh sudo bash lobe-rpi-install.sh
Note: To setup SSH, follow this guide (https://adafru.it/jvB).
© Adafruit Industries https://learn.adafruit.com/build-an-ml-package-detector Page 5 of 28
Download the Code
Download the GitHub repo into the Pi's home folder with the following commands:
cd ~ git clone https://github.com/lobe/lobe-adafruit-kit.git
The GitHub repo can also be found here (https://adafru.it/Rvb).
© Adafruit Industries https://learn.adafruit.com/build-an-ml-package-detector Page 6 of 28
Set up an FTP Connection
Since we're using the Pi in a headless configuration, we'll use an FTP connection to transfer files between
our computer and the Pi.
Windows Instructions
Download and install WinSCP (https://adafru.it/OcF)
Open WinSCP and start a New Session
Select an SFTP connection, fill in the IP address of your Pi, set the username to Pi, and put in your
password.
Your Pi's IP address is on the screen of the BrainCraft. You can also use the hostname address, e.g.
"raspberrypi.local" (pi@raspberrypi.local).
Mac Instructions
Download and install FileZilla (https://adafru.it/RuC). When it's done installing, open the program.
© Adafruit Industries https://learn.adafruit.com/build-an-ml-package-detector Page 7 of 28
Type sftp:// followed by the IP address of your Pi. Set the username to pi and put in your password.
Your Pi's IP address is on the screen of the BrainCraft. You can also use the hostname address, e.g.
"raspberrypi.local" (pi@raspberrypi.local).
© Adafruit Industries https://learn.adafruit.com/build-an-ml-package-detector Page 8 of 28
Collect Images
Before we can train an ML model, we need to collect some images. For this model, we'll need two
categories: images that have a package in them and images that don't.
To make our model more accurate under various weather conditions and other situations, it's useful to
have lots of pictures in both categories at different times of day and in different lighting conditions.
Install your Pi with the Camera pointing towards a package drop-off spot.
I installed my Pi just inside the door frame, with the camera outside and pointing down.
© Adafruit Industries https://learn.adafruit.com/build-an-ml-package-detector Page 9 of 28
Loading...
+ 19 hidden pages