Coral Accelerator 初探

Coral Accelerator 介绍

Coral Accelerator Coral Accelerator全名叫:Edge TPU Accelerator(边缘TPU加速器),是Google公司推出的新一款神经网络加速棒,相较于Movidius,外观上它采用了USB type-C的连接方式,避免了movidius那相当让人难受的笨重接头。与Movidius相同,它也同样是将云端训练的模型进行转换,起到终端神经网络本地推理的作用。
官网链接:https://coral.withgoogle.com/

环境配置

Coral Accelerator的环境配置在官网上有教程,首先尝试按照其Windows10教程进行配置,发现配置完成后,插上计算棒后无法检测到计算棒,会报如下错误:

Traceback (most recent call last):
  File "classify_image.py", line 122, in <module>
    main()
  File "classify_image.py", line 99, in main
    interpreter = make_interpreter(args.model)
  File "classify_image.py", line 73, in make_interpreter
    {'device': device[0]} if device else {})
  File "/usr/local/lib/python3.6/dist-packages/tflite_runtime/interpreter.py", line 164, in load_delegate
    library, str(e)))
ValueError: Failed to load delegate from libedgetpu.so.1

尝试一番后无果,选择放弃。
在Ubuntu16.04环境下进行安装:

Requirements

python3.5以上

安装 Edge TPU runtime

按照官方教程,采用apt的安装方法,但其https://packages.cloud.google.com/apt coral-edgetpu-stable的源被墙,无法直接进行安装。于是选择源码编译的方式对libedgetpu进行安装。
edgetpu源码:https://github.com/google-coral/edgetpu
(注:其中包含了大量已训练好的模型,git clone起来会相当慢。。。。)
运行 sripts/runtime/install.sh对Edge TPU Runtime进行安装即可。

安装TFlite

https://www.tensorflow.org/lite/guide/python
直接安装(根据自己的系统及python版本选择对应的包):

pip3 install https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp36-cp36m-linux_x86_64.whl

使用TensorFlow Lite API运行model

1、GitHub上clone实例代码

mkdir coral && cd coral
git clone https://github.com/google-coral/tflite.git

2、尝试运行分类网络,下载训练好的模型、label和测试图片:

cd tflite/python/examples/classification
bash install_requirements.sh

3、运行:

python3 classify_image.py \
--model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
--labels models/inat_bird_labels.txt \
--input images/parrot.jpg

输出:

INFO: Initialized TensorFlow Lite runtime.
----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
11.8ms
3.0ms
2.8ms
2.9ms
2.9ms
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.76562
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值