Install libraries

Install TensorFlow

For a Raspian base install, the only dependency that you need to add is TensorFlow.

First, install some TensorFlow prerequisites. Among these are Python 2. This guide has not been tested with Python 3.

Open a new terminal session and enter the following on the command line:

sudo apt update
sudo apt install python-dev python-pip
sudo apt install libatlas-base-dev     # required for numpy
sudo apt install libhdf5-dev
sudo pip install -U virtualenv         # system-wide install

Then install the latest version of TensorFlow:

sudo pip install --upgrade tensorflow

If you get a “Memory Error” message during the TensorFlow install, disable the cache during installation with this command:

sudo pip install --no-cache-dir tensorflow

You can verify the install with this command:

python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

If the TensorFlow installation is not verified, follow the guidance on the Install TensorFlow with pip page for Raspberry Pi with Python 2 as some of the requirements may have been updated.

Arm estimates the installation will take approximately 30-60 minutes.

Install Arm's training scripts

Download or clone our ML examples repository from GitHub and then navigate to the yeah-world directory by entering the following commands:

git clone
cd ML-examples/yeah-world

There is nothing special about these scripts, they are designed to be easy to understand and modify. Feel free to explore and hack them with your own changes.

Advanced information

The python source code is designed to be straightforward to follow and is split across these three files:

  • captures images from the camera and saves them to disk at the end.
  • loads saved images, converts them to features and trains a classifier on those features.
  • captures images from the camera, converts them to features, classifies them and then plays a random sound if they belong to the first category.

These three helper files are to keep the three source code files as readable as possible:

  • initializes the picamera module and optionally fluctuates the exposure and white balance during recording.
  • loads the pretrained MobileNet with TensorFlow and uses it to convert one image at a time into a set of features.
  • uses pygame to play a random sound file from a directory.
Before you begin Train the AI