在Edge TPU上跑TensorflowLite模型

一、Edge TPU开发板介绍

Edge TPU开发板是一款搭载了Edge TPU的单板计算机,功能非常丰富。开发板分为底板跟核心板,底板包括一些常用的外设接口,而核心板是基于Google Edge TPU的模块化系统子板(核心板与底板可以分离),也就是下图中带屏蔽罩的那个SOM(system-on-module )。

Edge TPU开发板购买途径:

1、去香港买,只要1500左右

2、在京东买,太贵3500左右,请仔细辨别

3、出国买或者请求国外的朋友买

Edge TPU的性能请参看:

https://github.com/freedomtan/edge_tpu_python_scripts

二、TPU的安装使用教程

https://www.mrtbc.com/318.html

https://post.smzdm.com/p/amm02q6k/

官方系列教程(需要翻墙)

https://coral.withgoogle.com/docs/edgetpu/retrain-detection/

三、在TPU上测试TensorflowLite模型

您现在可以使用Edge TPU Python API重新训练和编译的模型。

首先将模型,标签和图像复制到开发板(假设您通过USB连接;否则,您应该根据您的主板的IP地址更改命令):

然后,您可以使用classify_image.py示例脚本执行以下步骤,具体取决于您使用的设备。

1、创建ssh并复制文件到TPU,然后试运行

ssh-keygen

mdt pushkey ~/.ssh/id_rsa.pub

ssh [email protected]

2、下载可执行代码和模型

代码我已上传到github:

https://github.com/JackonLiu/TensorflowLite_TPU

模型和标签我已上传到CSDN下载:

https://download.csdn.net/user/qq_30803353/uploads

3、将文件复制到TPU根目录下的test文件夹(一定不要用中文的标点符号)

cd ../

cd mendel

mkdir test

scp -r  test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite test_data/inat_bird_labels.txt  test_data/parrot.jpg [email protected]:~/test

也可以直接将三个文件放到一个文件夹test里,复制文件夹到mendel里面

scp -r  test [email protected]:~/test

4、切换到Dev Board终端并导航到demo目录并运行classify_image.py脚本:

cd /usr/lib/python3/dist-packages/edgetpu/demo/

python3 classify_image.py \

    --model ~/test/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \

    --label ~/test/inat_bird_labels.txt \

    --image ~/test/parrot.jpg

python3 demo/object_detection.py \

--model edgetpu_models/mobilenet_ssd_v1_coco_quant_postprocess_edgetpu.tflite \ --input test_data/parrot.jpg

5、运行成功记截图

TPU跑图像分类模型

TPU跑对象检测模型

发布了16 篇原创文章 · 获赞 9 · 访问量 7136

猜你喜欢

转载自blog.csdn.net/qq_30803353/article/details/94203076