Hands on with the Coral USB Accelerator

Getting started with Google’s new Edge TPU hardware

The Coral USB Accelerator.

Opening the box

The Coral USB Accelerator
Comparing a first generation Movidius Neural Compute Stick (left), a second generation Intel Neural Compute Stick 2 (middle), and the new Coral USB Accelerator from Google (right).

Gathering the supplies

Everything you need to get started setting up the the Coral USB Accelerator.

Setting up your computer

% ssh pi@raspberrypi.local

Powering your Raspberry Pi

$ vcgencmd get_throttled
$ ./throttled.sh
Status: 0x50005
Undervolted:
Now: YES
Run: YES
Throttled:
Now: YES
Run: YES
Frequency Capped:
Now: NO
Run: NO
$
The current draw when the Raspberry Pi is idle, and the USB Accelerator is not in use.

Installing the software

$ wget http://storage.googleapis.com/cloud-iot-edge-pretrained-models/edgetpu_api.tar.gz
$ tar -xvzf edgetpu_api.tar.gz
$ cd python-tflite-source
$ bash ./install.sh
The Coral USB Accelerator is now ready.

Running your first Machine Learning model

$ python3 ./object_detection.py --model python-tflite-source/edgetpu/test_data/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --label python-tflite-source/edgetpu/test_data/coco_labels.txt --input fruit.jpg --output out.jpgbanana score =  0.839844
apple score = 0.5
Saved to out.jpg
$
$ scp pi@coral.local:out.jpg .
pi@coral's password:
out.jpg 100% 1249KB 9.9MB/s 00:00
$
Detecting fruit with a cut off for objects with a score < 0.45.
banana score =  0.839844
apple score = 0.5

book score = 0.210938
apple score = 0.210938
book score = 0.210938
dining table score = 0.160156
dining table score = 0.121094
banana score = 0.121094
apple score = 0.121094
book score = 0.121094
Detecting fruit with a much lower cut off score. Here we’re picking up the top 10 detections with a score>0.05.
Detecting fruit with a cut off for objects with a score < 0.45 in my original image from yesterday.
banana score =  0.964844
apple score = 0.789062
engine = DetectionEngine(args.model)
ans = engine.DetectWithImage(img, threshold=0.05, keep_aspect_ratio=True, relative_coord=False, top_k=10)
0  person
1 bicycle
2 car
3 motorcycle
4 airplane
5 bus
6 train
7 truck
8 boat
.
.
.
51 banana
52 apple

.
.
.
87 teddy bear
88 hair drier
89 toothbrush

Adding a camera

Attaching the Raspberry Pi camera module.
$ sudo shutdown -h now
The Raspberry Pi camera.
$ sudo raspi-config
$ raspistill -o testshot.jpg
My initial test image, showing the Coral Dev Board.
$ sudo apt-get install python3-picamera
$ cd ~
$
wget https://storage.googleapis.com/cloud-iot-edge-pretrained-models/canned_models/mobilenet_v2_1.0_224_quant_edgetpu.tflite
$ wget http://storage.googleapis.com/cloud-iot-edge-pretrained-models/canned_models/imagenet_labels.txt
$ cd ~/python-tflite-source/edgetpu
$
python3 demo/classify_capture.py \
--model test_data/mobilenet_v2_1.0_224_quant_edgetpu.tflite \
--label test_data/imagenet_labels.txt
View through the Pi Camera Module, with that pesky banana correctly identified.
Running this demo continuously results in a +10°C rise in temperature.

A comparison with the Coral Dev Board

A Raspberry Pi with Coral USB Accelerator (left) and Coral Dev Board (right).
$ time python3 ./object_detection.py --model python-tflite-source/edgetpu/test_data/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --label python-tflite-source/edgetpu/test_data/coco_labels.txt --input fruit.jpg --output out.jpgbanana score =  0.964844
apple score = 0.789062
Saved to out.jpg
real 0m6.586s
user 0m3.089s
sys 0m0.161s

$
$ time python3 ./object_detection.py --model /usr/lib/python3/dist-packages/edgetpu/test_data/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --label /usr/lib/python3/dist-packages/edgetpu/test_data/coco_labels.txt --input fruit.jpg --output out.jpgbanana score =  0.964844
apple score = 0.789062
Saved to out.jpg
real 0m1.505s
user 0m1.372s
sys 0m0.104s

$
banana score =  0.953125
apple score = 0.839844
banana score =  0.933594
apple score = 0.660156
The demo application included with the Coral Dev Board, showing inferencing at 79 fps.

Building your own models

Summary

Scientist, Author, Hacker, Maker, and Journalist.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store