For a Raspian base install the only dependency that you need to add is TensorFlow from Google’s binaries. First, install some TensorFlow prerequisites by entering the following in the command line:
sudo apt-get install libblas-dev liblapack-dev python-dev libatlas-base-dev gfortran python-setuptools python-h5py
# Replace this URL with the correct version for your Pi 3 or Zero: sudo pip2 install http://ci.tensorflow.org/view/Nightly/job/nightly-pi/lastSuccessfulBuild/artifact/output-artifacts/tensorflow-1.6.0rc1-cp27-none-any.whl
Install Arm's training scripts
Download or clone our ML examples repository from GitHub by entering the following on the command line:
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:
- record.py captures images from the camera and saves them to disk at the end.
- train.py loads saved images, converts them to features and trains a classifier on those features.
- run.py captures images from the camera, converts them to features, classifies them and then plays a random sound if they belong to the first category.
The three helper files are to keep the above three files as readable as possible:
- camera.py initializes the picamera module and optionally fluctuates the exposure and white balance during recording.
- pinet.py loads the pretrained MobileNet with TensorFlow and uses it to convert one image at a time into a set of features.
- randomsound.py uses pygame to play a random sound file from a directory.
|Overview||Train the AI|