Setup python environment (Ubuntu 20.04)

Get pip and virtualenv installed:

sudo apt-get install python3-pip
sudo apt-get update
sudo apt-get install python3-venv

Create a new environment and activate it:

python3 -m venv tf
source tf/bin/activate

Install the tensorflow library and, if needed, opencv:

pip install tensorflow
pip install opencv-contrib-python

Tensorflow lite

If there is no need to train models, a tansorflow lite environment can be used by itself. One needs to select the correct version from this list and install it. For example on Ubuntu 20.04 64bit:

pip3 install https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp37-cp37m-linux_x86_64.whl

The tensorflow interpreter can now be used as follows:

import tflite_runtime.interpreter as tflite
interpreter = tflite.Interpreter(model_path=args.model_file)

Coral usb accelerator

First install the coral dependencies:

sudo apt-get install curl

echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

sudo apt-get update

Finally install the coral library. There are two version available, the standard and the max version, which is faster but the usb device gets hot really fast. NB: only one version can be installed in the system. Installing a different one will override the previous.

# standard:
sudo apt-get install libedgetpu1-std

# max:
sudo apt-get install libedgetpu1-max