树莓派4B_tensorflow
安装python virtualenv
- 远程ssh登陆操作
ping raspberrypi.local
- 获取树莓派的内网ip,我的是 192.168.1.6,ssh登陆并输入密码:
ssh pi@192.168.1.6
- 安装Python
python --version
1 | # 安装venv |
安装TensorFlow Lite
从github下载pi4b_tensorflow_lite1
2
3
4
5
6
7
8
9
10
11
12
13
14
15git clone https://github.com/whgreate/pi4b_tensorflow_lite
# 安装tensorflow lite
$ pip install tflite_runtime-1.14.0-cp37-cp37m-linux_armv7l.whl
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing ./tflite_runtime-1.14.0-cp37-cp37m-linux_armv7l.whl
Installing collected packages: tflite-runtime
Successfully installed tflite-runtime-1.14.0
# numpy pillow库需要的一些依赖
$ sudo apt-get install libatlas-base-dev
$ sudo apt-get install libjpeg-dev
# 安装 numpy pillow
$ pip install -r requirements.txt
进行测试
运行图像分类模型
选取TensorFlow Example的图片,执行以下命令:1
2
3
4
5
6
7
8
9python label_image.py -m mobilenet_v1_1.0_224_quant.tflite -l labels_mobilenet_quant_v1_224.txt -i grace_hopper.bmp
INFO: Initialized TensorFlow Lite runtime.
0.658824: military uniform
0.149020: Windsor tie
0.039216: bow tie
0.027451: mortarboard
0.019608: bulletproof vest
用摄像头拍摄一张照片进行测试:1
2
3
4
5
6
7
8
9
10
11raspistill -o demo.jpg
python label_image.py -m mobilenet_v1_1.0_224_quant.tflite -l labels_mobilenet_quant_v1_224.txt -i demo.jpg
0.266667: barbershop
0.098039: potter's wheel
0.050980: laptop
0.043137: barber chair
0.043137: shoe shop
- 本文链接:http://www.codekp.cn/2021/06/07/%E6%A0%91%E8%8E%93%E6%B4%BE4B-tensorflow/
- 版权声明:本博客所有文章除特别声明外,均默认采用 许可协议。
您可以点击下方按钮切换对应评论系统。
GitHub Issues