Suivons le guide de démarrage : Get started with the USB Accelerator
Vérifiez la version d’Ubuntu utilisée :
moore@neuralux:~$ sudo lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
Nous commençons par mettre à jour le système Ubuntu :
moore@neuralux:~$ sudo apt update
[sudo] password for moore:
Hit:1 http://fr.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://fr.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://fr.archive.ubuntu.com/ubuntu bionic-backports InRelease
Get:4 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [22.7 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 48x48 Icons [10.4 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons [31.7 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [42.1 kB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [16.4 kB]
Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [111 kB]
Get:11 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Fetched 326 kB in 1s (428 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Nous pouvons télécharger le runtime Edge TPU et les librairies Python :
moore@ubuntux:~$ mkdir src
moore@ubuntux:~$ cd src/
moore@ubuntux:~/src$ wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names
moore@neuralux:~/src$ ls -lah edgetpu_api.tar.gz
-rw-rw-r-- 1 moore moore 4.9M Jul 23 22:13 edgetpu_api.tar.gz
Nous pouvons décompresser l’archive :
moore@neuralux:~/src$ tar xvzf edgetpu_api.tar.gz
edgetpu_api/
edgetpu_api/uninstall.sh
edgetpu_api/99-edgetpu-accelerator.rules
edgetpu_api/edgetpu-2.11.1-py3-none-any.whl
edgetpu_api/libedgetpu/
edgetpu_api/libedgetpu/libedgetpu_arm32_throttled.so
edgetpu_api/libedgetpu/libedgetpu_arm32.so
edgetpu_api/libedgetpu/libedgetpu_arm64.so
edgetpu_api/libedgetpu/libedgetpu_arm64_throttled.so
edgetpu_api/libedgetpu/libedgetpu_x86_64_throttled.so
edgetpu_api/libedgetpu/libedgetpu_x86_64.so
edgetpu_api/install.sh
Avertissement de Google, lors de l’installation, il vous sera demandé : “Souhaitez-vous activer la fréquence de fonctionnement maximale ? L’activation de cette option améliore la vitesse d’inférence, mais l’accélérateur USB devient également très chaud au toucher pendant le fonctionnement et peut provoquer des brûlures.
Installez le runtime Edge TPU et la bibliothèque Python :
moore@neuralux:~/src$ sudo edgetpu_api/install.sh
Recognized as Linux on x86_64.
Warning: During normal operation, the Edge TPU Accelerator may heat up, depending
on the computation workloads and operating frequency. Touching the metal part of the
device after it has been operating for an extended period of time may lead to discomfort
and/or skin burns. As such, when running at the default operating frequency, the device is
intended to safely operate at an ambient temperature of 35C or less. Or when running at
the maximum operating frequency, it should be operated at an ambient temperature of
25C or less.
Google does not accept any responsibility for any loss or damage if the device is operated
outside of the recommended ambient temperature range.
.............................................................
Would you like to enable the maximum operating frequency? Y/N
Y
...
Done.
Installing device rule file [/etc/udev/rules.d/99-edgetpu-accelerator.rules]...
Done.
Installing Edge TPU runtime library [/usr/lib/x86_64-linux-gnu/libedgetpu.so.1.0]...
Done.
Installing Edge TPU Python API...
The directory '/home/moore/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/moore/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Processing ./edgetpu_api/edgetpu-2.11.1-py3-none-any.whl
Installing collected packages: edgetpu
Successfully installed edgetpu-2.11.1
Done.
Branchez votre TPU USB Google Coral, vérifiez si vous pouvez trouver le périphérique USB :
moore@neuralux:~$ lsusb | grep Unichip
Bus 001 Device 003: ID 1a6e:089a Global Unichip Corp.
Téléchargez le modèle de classificateur bird, le fichier des labels, et les photos :
moore@neuralux:~/src$ wget https://dl.google.com/coral/canned_models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
https://dl.google.com/coral/canned_models/inat_bird_labels.txt \
https://coral.withgoogle.com/static/docs/images/parrot.jpg
Contrôlez les librairies installées :
moore@neuralux:~/src$ cd /usr/local/lib/python3.6/dist-packages/edgetpu/demo
moore@neuralux:/usr/local/lib/python3.6/dist-packages/edgetpu/demo$ ls
backprop_last_layer.py classify_capture.py object_detection.py two_models_inference.py
classification_transfer_learning.py classify_image.py __pycache__
Lancez le classificateur :
python3 classify_image.py \
--model /home/moore/src/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
--label /home/moore/src/inat_bird_labels.txt \
--image /home/moore/src/parrot.jpg
Succès, nous pouvons trouver le péroquet \o/ :
moore@neuralux:/usr/local/lib/python3.6/dist-packages/edgetpu/demo$ python3 classify_image.py \
> --model /home/moore/src/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
> --label /home/moore/src/inat_bird_labels.txt \
> --image /home/moore/src/parrot.jpg
INFO: Initialized TensorFlow Lite runtime.
---------------------------
Ara macao (Scarlet Macaw)
Score : 0.761719