Google Coral USB Accelerator


Seguiremos la documentación de inicio: Get started with the USB Accelerator

Installing the Google Coral Edge TPU software

Revisa tu versión de Ubuntu en funcionamiento:

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

Primero actualiza tu sistema 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.

Descargue el tiempo de ejecución de TPU Edge y la biblioteca de 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

Extraiga el archivo:

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

Advertencia de Google, durante la instalación, se le preguntará: “¿Quiere habilitar la frecuencia máxima de funcionamiento?” Activar esta opción mejora la velocidad de inferencia pero también hace que el Acelerador USB se caliente mucho al tacto durante el funcionamiento y puede causar quemaduras.

Instala el tiempo de ejecución del TPU Edge y la biblioteca de 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.

Conecta tu USB Google Coral, comprueba si puedes encontrarlo:

moore@neuralux:~$ lsusb | grep Unichip
Bus 001 Device 003: ID 1a6e:089a Global Unichip Corp. 

Ejecutar un modelo en el TPU Edge

Descargue el modelo de clasificador de aves, el archivo de etiquetas y la foto:

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

Revisa la biblioteca instalada :

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__

Lanza el clasificador :

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

Éxito, podemos encontrar el loro \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


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

EN | FR | ES

Búsqueda