Image classification example (deprecated)

Note: This example and the APIs used in it are no longer maintained. We recommend you instead use this example using the TF Lite APIs.

This example performs image classification with ClassificationEngine from the Edge TPU API, using the given classification model, labels file, and image.

In this example, we're using a MobileNet model trained with the iNaturalist birds dataset, so it's great at identifying different types of birds.

Before you begin, you must have already set up your Dev Board or USB Accelerator.

Download the Edge TPU API examples

echo "deb coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list

curl | sudo apt-key add -

sudo apt-get update

sudo apt-get install edgetpu-examples

The examples are saved at /usr/share/edgetpu/examples/.

Caution: If you first set up your device prior to our v2.12.1 update (Sep 25, 2019), then running the following examples might cause conflicts with your previous version of the Edge TPU library. To resolve, follow the steps to set up our new Debian packages.

Run the code

cd /usr/share/edgetpu/examples/

python3 \
--model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
--label models/inat_bird_labels.txt \
--image images/parrot.jpg
Figure 1. parrot.jpg

You should see results like this:

Ara macao (Scarlet Macaw)
Score :  0.61328125
Platycercus elegans (Crimson Rosella)
Score :  0.15234375

See the source here.

To create your own classification model, read the tutorial about how to Retrain an image classification model.

parrot.jpg is licensed under Creative Commons by Tony Hisgett.