Google Coral USB Accelerator を試す その4

TensorFlow Lite Python classification example with Pi Camera を、TPUに差し替えてためそう

$ git clone https://github.com/tensorflow/examples --depth 1
$ cd examples/lite/examples/image_classification/raspberry_pi
$ bash download.sh ~/models

まずは Tensorflow lite で

python3 classify_picamera.py  --model ~/models/mobilenet_v1_1.0_224_quant.tflite  --labels ~/models/labels_mobilenet_quant_v1_224.txt

動きましたが、ハングアップしました。。。

TPUに書き換える

$ cp classify_picamera.py classify_picamera_tpu.py

from tflite_runtime.interpreter import load_delegate interpreter = Interpreter(args.model, experimental_delegates=[load_delegate('libedgetpu.so.1.0')])

$ python3 classify_picamera_tpu.py --model ~/models/mobilenet_v1_1.0_224_quant_edgetpu.tflite --labels ~/models/labels_mobilenet_quant_v1_224.txt
$ python3 classify_picamera_tpu.py --model ~/models/mobilenet_v2_1.0_224_quant_edgetpu.tflite --labels ~/models/imagenet_labels.txt
$ python3 classify_picamera_tpu.py --model ~/models/inception_v4_299_quant_edgetpu.tflite --labels ~/models/imagenet_labels.txt

Detect もためそう

$ cd ~/examples/lite/examples/object_detection/raspberry_pi

$ python3 detect_picamera_tpu.py --model ~/models/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --labels ~/models/coco_labels.txt
$ python3 detect_picamera_tpu.py --model ~/models/mobilenet_ssd_v2_face_quant_postprocess_edgetpu.tflite --labels ~/models/coco_labels.txt

f:id:pongsuke:20191127140859p:plain

残念!
それはマグカップだ!
ぜひとも Coffee mug と答えて欲しかった。