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 pip install -U virtualenv # system-wide install
Then install the latest version of TensorFlow:
sudo pip install --upgrade 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.
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:
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.
The python source code is designed to be straightforward to follow and is split across these three files:
record.pycaptures images from the camera and saves them to disk at the end.
train.pyloads saved images, converts them to features and trains a classifier on those features.
run.pycaptures 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:
camera.pyinitializes the picamera module and optionally fluctuates the exposure and white balance during recording.
pinet.pyloads the pretrained MobileNet with TensorFlow and uses it to convert one image at a time into a set of features.
randomsound.pyuses pygame to play a random sound file from a directory.
|Overview||Train the AI|