Edge Impulse is an online tool that makes training and deploying machine learning to the edge a breeze. Their built-in optimizations means that your models will be smaller and faster than most models of comparable accuracy, and far easier to train.
Thankfully, the Edge Impulse Linux SDK makes it easy to get set up and start collecting data, training, and running inference on Avnet’s MaaXBoard.
Previously, I showed how to get started with the Node.js SDK on MaaXBoard Mini with this hard hat detection project on Hackster:
However, if you're like me and the only programming language that makes sense to you anymore is Python, you'll probably want to install the Python SDK for Edge Impulse.
Here, I’ll show how to set up the Python SDK on Debian Linux on MaaXBoard. Even though the MaaXBoard looks like a Raspberry Pi because it has the same form factor, you'll need to use the same instructions as the Jetson Nano when installing the Linux SDK for both Python and Node.js.
Step 1: install pip & set up a virtual environment
The Debian image for MaaXBoard ships with Python 3 already installed, but you'll need to install pip yourself. Once that's done, it's always a good idea to set up a virtual environment.
From your home folder use these commands to download PIP (package installer for python):
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 ./get-pip.py
then install the package itself and remove the leftovers:
sudo pip install virtualenv virtualenvwrapper
rm -rf ~/get-pip.py ~/.cache/pip
now as user “ebv” (this was created in the prerequisite headless setup) we edit our bash shell configuration file ~/.bashrc using nano:
nano ~/.bashrc
and at the very bottom of it we add these lines:
# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
Save with CTRL+O, exit with CTRL+X and make sure you reload your shell config with:
source ~/.bashrc
Now we can create the “ei” virtual environment (“ei” for edge impulse) itself with the command:
mkvirtualenv ei -p python3
You can enter the “ei” virtual environment by typing:
workon ei
Step 2: install the dependencies & the Edge Impulse module
While still in your virtual environment, install the dependencies:
sudo apt-get install libatlas-base-dev libportaudio2 libportaudiocpp0 portaudio19-dev
And now you can install the Edge Impulse Linux SDK:
pip3 install edge_impulse_linux
Finally, you can clone the Linux SDK Python repository from github to get examples:
git clone https://github.com/edgeimpulse/linux-sdk-python
Now that the SDK is installed, you can follow the same steps outlined in the hard hat detection project to collect data, train a model, and start inferencing!